MathGroup Archive 2009

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

Search the Archive

Re: More /.{I->-1} craziness

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106035] Re: More /.{I->-1} craziness
  • From: "Alexander Elkins" <alexander_elkins at hotmail.com>
  • Date: Thu, 31 Dec 2009 03:13:38 -0500 (EST)
  • References: <hhf5s3$h4o$1@smc.vnet.net>

You'll get the same behavior for similar reasons if you try the following:

In[1]:= -1/2 /. 1/2 -> -1/2
Out[1]= -(1/2)

The reason is that what you see is not what is acted upon, for example:

In[2]:= FullForm[{1/-2,I,-I,1+I,1-I,1/-2+I/-3}]
Out[2]//FullForm=
List[Rational[-1,2],Complex[0,1],Complex[0,-1],Complex[1,1],Complex[1,-1],Co
mplex[Rational[-1,2],Rational[-1,3]]]

In other words -I is seen as Complex[0,-1] not -Complex[0,1], Complex[0,1]
does not match anything, so no replacement is performed leaving the input
unchanged. One way to change -I to -(-I) is as follows:

In[3]:= -I/.Complex[r_,i_]:>Complex[r,-i]
Out[3]= I

That also works in this more general case:

In[4]:= 1/-2+I/-3/.Complex[r_,i_]:>Complex[r,-i]
Out[4]= -(1/2)+I/3

Hope this helps...

"AES" <siegman at stanford.edu> wrote in message
news:hhf5s3$h4o$1 at smc.vnet.net...
> The more I play with these I->-I substitution rules, the more seemingly
> wildly inconsistent results emerge.  For example:
>
>    In[1]:= -I/.I->-I
>
>    Out[1]= -I
>
>    In[3]:= -E/.E->-E
>
>    Out[3]= << The Esc e e Esc symbol >>
>
>    In[4]:= -Pi/.Pi->-Pi
>
>    Out[4]= \[Pi]
>
>    In[5]:= -Infinity/.Infinity->-Infinity
>
>    Out[5]= -\[Infinity]
>
> (In/Out[2] is removed because it was an irrelevant cell.)
>




  • Prev by Date: Re: Persistent assumption
  • Next by Date: Re: More /.{I->-1} craziness
  • Previous by thread: Re: More /.{I->-1} craziness
  • Next by thread: Re: More /.{I->-1} craziness