Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Complex Oddity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57535] Re: Complex Oddity
  • From: "John Reed" <nospamjreed at alum.mit.edu>
  • Date: Tue, 31 May 2005 05:00:21 -0400 (EDT)
  • References: <d79enu$lbl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks to all who explained what is happening and how to work this problem 
correctly.  Now I know one facet of working with complex numbers.  I don't 
feel much better about this however.  I received one e-mail that said this 
was my fault for not reading the documentation closely enough.  This problem 
came up in the book "Mathematica for Physics" second edition by Zimmerman 
and Olness.  They solve a problem using the Complex[a_,b_]->a rule, ( see 
page 91) but not the b part.  The b part was my idea.  Now I know why they 
didn't solve for the imaginary part this way.  They get the imaginary part 
by subtracting the real part from the complex expression and dividing by I. 
How many other gotchas are hidden in the code, waiting to bite the unwary 
and relatively new user?  What documentation tells about this kind of a 
problem or do I just have to find them for myself by hopefully catching the 
errors as they occur?

John Reed

"John Reed" <nospamjreed at alum.mit.edu> wrote in message 
news:d79enu$lbl$1 at smc.vnet.net...
>I was trying to separate the real and imaginary parts of a complicated
> expression, and ended up with something strange.  Here is a short version 
> of
> what happened.
>
> Let z = x + I y, then realPart = z /. {Complex[a_,b_]->a} gives realPart =
> x.  Great!
>
> Now, try imagPart = z /. {Complex[a_,b_]->b}  returns with imagPart = x + 
> y.
> Oops
>
> In my original expression, it was harder to see, but the same error was
> occuring.  What I tried first was using Re[z] and Im[z], but then I have 
> to
> work with Im[y] and Im[x].  It seems to me two things need to be done 
> here.
> First, be able to assign variables so that they always stay real or else
> indicate an error is occuring if they turn out to be complex, and second 
> do
> something to avoid errors like the above.  I have to say that I don't 
> trust
> Mathematica's answers as much as I did before this came up. Now I feel 
> like
> I better have a good idea of what the answer is before I  trust 
> Mathematica.
>
> John Reed
>
> 


  • Prev by Date: Re: Two related question. Question 1
  • Next by Date: Re: Related quastions. Question 2
  • Previous by thread: Re: Complex Oddity
  • Next by thread: global fit