MathGroup Archive 2000

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

Search the Archive

Re: selfdefined operators

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23006] Re: [mg22989] selfdefined operators
  • From: Hartmut Wolf <hwolf at debis.com>
  • Date: Mon, 10 Apr 2000 02:22:32 -0400 (EDT)
  • Organization: debis Systemhaus
  • References: <200004090545.BAA13108@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Roland Koppenberger schrieb:
> 
> I have defined the operator \[CirclePlus] in the following way:
> 
> x_ \[CirclePlus] y_ := x y /(x + y)
> 
> When type in
> 
> 1 \[CirclePlus] 2
> 
> I get 2/3 as the right result. But when I try to compute
> 
> 1 \[CirclePlus] 2 \[CirclePlus] 3
> 
> the result will not be computed. How can I specify the operator in a
> general way?


Roland,

if you consult The Mathematica Book p. 1015 you'll find the operator
CirclePlus to be defined as fully associative. If you respect that,
you'll have no problems (in case you know how to define it for many
arguments). Two suggestions; #1:
 
In[1]:= SetAttributes[CirclePlus, {Flat, OneIdentity}]
In[2]:= CirclePlus[x__] := Times[x]/Plus[x]
In[3]:= 1\[CirclePlus]2
Out[3]= 2/3

In[4]:= 1\[CirclePlus]2\[CirclePlus]3
Out[4]= 1

In[5]:= 1\[CirclePlus]2\[CirclePlus]3\[CirclePlus]4
Out[5]= 12\5

or #2:
 
In[13]:= CirclePlus[x1_, x__] := Fold[(#1 #2/(#1 + #2) &), x1, {x}]
In[14]:= 1\[CirclePlus]2
Out[14]= 2/3

In[15]:= 1\[CirclePlus]2\[CirclePlus]3
Out[15]= 6/11

In[16]:= 1\[CirclePlus]2\[CirclePlus]3\[CirclePlus]4
Out[16]= 12/25


Hartmut


  • Prev by Date: Re: selfdefined operators
  • Next by Date: Re: M4 Problems with Initialization Cells
  • Previous by thread: selfdefined operators
  • Next by thread: Re: Re: selfdefined operators