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: [mg45057] Re: Replacement rules with I (sqrt(-1)
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
  • Date: Mon, 15 Dec 2003 06:02:52 -0500 (EST)
  • References: <brhi2e$jha$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jean-Michel Collard <jm at france-paris.org> wrote:
> Can someone explain me this particular behavior :
>
> x+I*y /. I -> -I
>
> x-I y  (*  ok  *)
>
> 3+I /. I-> -I
>
> 3+I     (*  ????? false  *)

The key, I believe, is to look at their FullForm:

In[1]:= FullForm[I]

Out[1]//FullForm= Complex[0,1]

In[2]:= FullForm[3+I]

Out[2]//FullForm= Complex[3,1]

In[3]:= FullForm[x+I*y]

Out[3]//FullForm= Plus[x,Times[Complex[0,1],y]]

So x+I*y /. I -> -I worked as you wished because Mathematica was able to
"see" Complex[0,1] in the expression Plus[x,Times[Complex[0,1],y]]. OTOH,
3+I /. I-> -I did not work as you wished because no Complex[0,1] is to be
seen in Complex[3,1]. You would have been happier here if FullForm of
3+I had been Plus[3,Complex[0,1]] instead.

David


  • Prev by Date: Re: Replacement rules with I (sqrt(-1)
  • Next by Date: RE: Replacement rules with I (sqrt(-1)
  • Previous by thread: Re: Replacement rules with I (sqrt(-1)
  • Next by thread: RE: Replacement rules with I (sqrt(-1)