MathGroup Archive 2003

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

Search the Archive

Re: Replacement rules with I (sqrt(-1)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45056] Re: [mg45053] Replacement rules with I (sqrt(-1)
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 15 Dec 2003 06:02:51 -0500 (EST)
  • References: <200312141122.GAA19834@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 14 Dec 2003, at 20:22, Jean-Michel Collard wrote:

> Can someone explain me this particular behavior :
>
> x+I*y /. I -> -I
>
> x-I y  (*  ok  *)
>
>
> 3+I /. I-> -I
>
> 3+I     (*  ????? false  *)
>
> Regards,
>
> J.-M.
>
(I suspect you will get a food of explanations, so I am a little 
reluctant to contribute, but who knows ... sometimes everybody thinks 
like this and nobody answers ...)

When you use replacement rules you should look at the FullForm of the 
expression you are trying to perform replacement on:


FullForm[x + I*y]

Plus[x,Times[Complex[0,1],y]]


Since the FullForm of I is just Complex[0,1] your replacement works. 
However,


FullForm[3+I]]

Complex[3,1]

and as you see, there is no I (Complex[0,1]) in it at all. So not 
surprisingly your replacement doesn't work. There are lots of ways to 
make it work, for example in this case you can just use:


x+I y/. Complex[a_,b_]->Complex[a,-b]


x-I y


3+I/.Complex[a_,b_]->Complex[a,-b]

3-I




Andrzej Kozlowski


  • Prev by Date: RE: Replacement rules with I (sqrt(-1)
  • Next by Date: Out of Memory under AIX (Mathematica 5)
  • Previous by thread: Replacement rules with I (sqrt(-1)
  • Next by thread: Re: Replacement rules with I (sqrt(-1)