Re: complex math error? [message #4339 is a reply to message #4289] |
Fri, 19 May 1995 00:00   |
heard
Messages: 5 Registered: May 1995
|
Junior Member |
|
|
In Article <3pgkmo$b3s@post.gsfc.nasa.gov>, thompson@orpheus.nascom.nasa.gov
(William Thompson) wrote:
> heard@drep.dnd.ca (Garry J. Heard) writes:
>
>> Hi,
>
>> I think we've found an erratic math error in IDL V3.6 (running on a PPC and
>> an SGI results were similar). Here it is:
>
>
>> print, exp( complex(0,1)*sqrt(2.)*10. )^sqrt(2.)
>
>> Execute the above line a time or two and you'll get the wrong answer, then try
>> almost any simple math operation on a complex number. i.e.,
>
>> print, complex(0,1)^2
>
>> Chances are you'll get a wrong answer again. Try the last operation again
>> and you might then get the correct answer. It's an erratic sort of bug and
>> seems to have a lot to do with complex numbers and sqrt functions. But it
>> is unpredictable. The only way we have been able to induce it so far is to
>> raise a complex exponential to a power involving a sqrt. I guess you should
>> be wary of any complex math in IDL until RSI has had a look at it. Also, the
>> bug may not exist in V4. I think that WAVE may not allow these kinds of
>> operations on complex values, so in a way that will protect you from this
>> bug (I might be wrong about this since I don't have a current WAVE version
>> to try it on).
>
> I can't make it fail running IDL 3.6.1c under OSF/1 v2.0 on an AXP 3000/600
> workstation. I always get the result
>
> IDL> print, exp( complex(0,1)*sqrt(2.)*10. )^sqrt(2.)
> ( -1.28269e-10, 1.66070e-10)
>
> no matter how many times I try it. (I assume that's the correct value.) Also,
> I always get
>
> IDL> print, complex(0,1)^2
> ( -1.00000, 0.00000)
>
> Bill Thompson
Hi Bill,
Sorry. That answer is wrong. exp[i z] will always have a magnitude of 1.
This turns out to be an impossible problem anyway since there are several
roots to the solution, but each of them must have a unit modulus. It's odd
that you always get the other problem to work properly after getting the
previous one wrong, but I did say that it was unpredictable. I've done it
quite a few times and never gotten exactly the same results.
In any case, I must tell you that RSI responded very quickly to my e-mail
to their support department. They were aware of the bug and have fixed it
in V4.0 that is now being shipped.
Also, I had some friends try it on PV-WAVE and they can't do it at all.
WAVE only appears to have marginal complex number support. WAVE users
should try squaring a complex number, I think they will get an illegal
operation error.
------------------------------------------------------------ -----------
Garry J. Heard EDRD
heard@edrd.dnd.ca
604/363-2905
Any opinions expressed are my own and not necessarily those of my employer.
|
|
|