[Date Index]
[Thread Index]
[Author Index]
Re: Unwanted Recursion
*To*: mathgroup at smc.vnet.net
*Subject*: [mg120097] Re: Unwanted Recursion
*From*: Kambis Veschgini <k.veschgini at thphys.uni-heidelberg.de>
*Date*: Fri, 8 Jul 2011 04:53:12 -0400 (EDT)
*References*: <iv1a95$sjl$1@smc.vnet.net> <iv4637$f8u$1@smc.vnet.net>
On 2011-07-07 13:42:31 +0200, Bill Rowe said:
> On 7/6/11 at 5:39 AM, casorati at f-m.fm (Casorati) wrote:
>
>> I'm trying to define an anti-commutative algebra in Mathematica.
>> Here I will show only a minimal example to demonstrate my point. The
>> product of two elements a^b should be give by p[a,b] so I make p
>> flat:
>
> Unless you are inventing new syntax a^b is not the product of a
> and b. It is a raised to the b power.
I am defining a new product called p. a^b^c should be represented in
mathematica by p[a,b,c]
and so on.
>
>> SetAttributes[p, {Flat}]
>
>> But now I want p[a] to reduce to a. Such a rule would make other
>> rules much simpler but when I define
>
>> p[a_] := a
>
>> the expression p[a] causes an infinite recursion. I get the message
>
>> $IterationLimit::itlim: Iteration limit of 4096 exceeded.
>
> While I cannot explain precisely why this message occurs I can
> confirm I get the same result when I set the attributes for p to
> be Flat. However, if I do not set the attributes of p then
> things work fine as demonstrated by:
>
> In[1]:= p[a_] := a
>
> In[2]:= p[a]
>
> Out[2]= a
I get the iterative behaviour executing this code (Mathematica 8 under
Linux and Mac, I can't test it under Windows).
>
> and given that p has been defined with a single argument, it
> makes no sense for it to also have the attribute Flat.
For this reason mathematica should replace it by the argument itself.
This makes writing other rules for example chain rule for derivatives
much easier.
>
> If you were to define p to take an arbitrary number of arguments
> and give it the attribute Flat, i.e.,
>
> In[6]:= Clear[p]
>
> In[7]:= SetAttributes[p, {Flat}]
>
> In[8]:= p[a__] := a
>
> In[9]:= p[a, b]
>
> Out[9]= Sequence[a,b]
>
> the error message doesn't occur.
But I want p[a,b] to stay as p[a,b] brcause it represents the product
of a and b. Consider them beeing Grassmann Numbers for example.
Prev by Date:
**Re: How to write a "proper" math document**
Next by Date:
**Re: How to NSolve equation which involves NIntegrate?**
Previous by thread:
**Re: Unwanted Recursion**
Next by thread:
**Re: Unwanted Recursion**
| |