MathGroup Archive 2000

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

Search the Archive

Re: selfdefined operators

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23001] Re: selfdefined operators
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 10 Apr 2000 02:22:29 -0400 (EDT)
  • References: <8cp5rj$csm@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Roland Koppenberger" <roland at koppenberger.com> wrote in message
news:8cp5rj$csm at smc.vnet.net...
> 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:

First, we get
FullForm[x\[CirclePlus]y]

        CirclePlus[x, y]

(in other words, Mathematica changes our input into this form before evaluation)

Noting this, we take your definition

x_ \[CirclePlus] y_ := x y /(x + y)

and add

CirclePlus[x_, y_, z__] := CirclePlus[x, CirclePlus[y, z]]

Now we get

x\[CirclePlus]y\[CirclePlus]z


        (x*y*z)/((y + z)*(x + (y*z)/(y + z)))

You may want the association to be on the other side.

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565







  • Prev by Date: Re: Mod Bessel function bug ?
  • Next by Date: Re: selfdefined operators
  • Previous by thread: RE: selfdefined operators
  • Next by thread: M4 Problems with Initialization Cells