MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Orderless indexed functions

  • To: mathgroup at
  • Subject: [mg20920] Re: [mg20906][mg20874] Orderless indexed functions
  • From: Hartmut Wolf <hwolf at>
  • Date: Wed, 1 Dec 1999 01:49:52 -0500 (EST)
  • Organization: debis Systemhaus
  • References: <001a01bf33e5$bebf5200$86ac153f@satellite>
  • Sender: owner-wri-mathgroup at

N Monomachoff schrieb:
> Dear Andrzej Kozlowski,
> I want to thank you for the extraordinary efforts you've expended on this
> problem. Had I appreciated how nontrivial my original question was, I
> would have been much more explicit:
> Not only do I need pattern matching within the body of the function, I need
> to pattern match the index itself, as in the following:
> f[n_][x___,f[0][y___]]:=f[n][x,y]
> The ability to do this is precisely why I chose the indexed form.
> Unfortunately, none of the proposed solutions, not even your last, seems to
> allow for such definitions. Apparently the Notation package is unable to
> stretch this far. Even a definition as simple as:

Dear N Monomachoff,

if you need the 'indexes' to f to express recursion relations, while
having the Orderless attribute, you might try as follows:

Instead of writing  f[n_][x___,f[0][y___]]:=f[n][x,y] take the 'index'
to the arguments. But of course you can't use a plain number, to do that
(at least if you ever have numerical arguments), so wrap it with some
marking head, I took capital greek Xi for the example.

In[1]:= SetAttributes[f, Orderless]
f[x___, f[y___, \[CapitalXi][0]], \[CapitalXi][n_]] := 
  f[x, y, \[CapitalXi][n]]

In[3]:= f[\[CapitalXi][3], 7, 5, f[\[CapitalXi][0], 6, 4]]
Out[3]= f[4, 5, 6, 7, \[CapitalXi][3]]

The standard evaluation procedure will move our tag to the end and such
recognize the recursion relation, substitute and proceed further. This
works as long as you use numerical arguments and (roman) alphabetical
symbols and expressions with such heads. So 

f[\[CapitalXi][3], t, r, f[\[CapitalXi][0], s, 4, a^2 - b^2], 
  x + y^3 - g[Sqrt[x - \[CapitalOmega][5]]]]
f[4, a^2 - b^2, r, s, t, x + y^3 - g[Sqrt[x - \[CapitalOmega][5]]], 

also should do.

Perhaps that will work in your case.

Kind regards, Hartmut

  • Prev by Date: Re: Running Mathematica under Linux Red Hat
  • Next by Date: Re: Running Mathematica under Linux Red Hat
  • Previous by thread: Re: Re: Running Mathematica under Linux Red Hat
  • Next by thread: Re: Re: Orderless indexed functions