complex math error? [message #4289] |
Wed, 17 May 1995 00:00  |
heard
Messages: 5 Registered: May 1995
|
Junior Member |
|
|
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).
------------------------------------------------------------ -------------------
Garry J. Heard heard@edrd.dnd.ca
Esquimalt Defence Research Detachment
Victoria, B.C., Canada
604/363-2905
Any opinions expressed are my own and not necessarily those of my employer.
------------------------------------------------------------ -------------------
|
|
|
Re: complex math error? [message #4304 is a reply to message #4289] |
Tue, 23 May 1995 00:00  |
asb
Messages: 13 Registered: May 1994
|
Junior Member |
|
|
In article <heard.1151115158F@131.136.96.1> heard@drep.dnd.ca (Garry J. Heard) writes:
Newsgroups: comp.lang.idl-pvwave
Path: nih-csl!darwin.sura.net!mojo.eng.umd.edu!bloom-beacon.mit.ed u!panix!news.mathworks.com!news.kei.com!ub!netfs.dnd.ca!drep .dnd.ca!131!heard
From: heard@drep.dnd.ca (Garry J. Heard)
Sender: nobody@drep.dnd.ca
Organization: Esquimalt Defence Research Detachment
Date: Wed, 17 May 1995 16:18:38 GMT
X-Newsreader: VersaTerm Link v1.1.3
Lines: 33
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.
The error appears to occur only when complex numbers and real numbers
are used with certain functions. The command
print, exp( complex(0,1)*sqrt(2.)*10. )^complex(sqrt(2.),0)
gives the correct result.
|
|
|
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.
|
|
|
Re: complex math error? [message #4348 is a reply to message #4289] |
Fri, 19 May 1995 00:00  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
llobet@elpp1.epfl.ch (Xavier Llobet i Sales EPFL-CRPP 1015 Lausanne CH) writes:
> In article <3pgkmo$b3s@post.gsfc.nasa.gov>, thompson@orpheus.nascom.nasa.gov
> (William Thompson) writes:
> [...]
> =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.)
> Nope. Just try
> IDL> print, exp( complex(0,1)*sqrt(2.)*10. )^sqrt(2.D0)
> ( -0.611276, 0.791417)
> This gives the right value.
> -xavier
Hmmm, when I tried this with IDL 3.6.1c I get
IDL> print, exp( complex(0,1)*sqrt(2.)*10. )^sqrt(2.D0)
( -0.0477381, -0.00519184)
Which is significantly different from either of the above. However, when I
tried this in a beta test version of IDL 4, I get
IDL> print, exp( complex(0,1)*sqrt(2.)*10. )^sqrt(2.D0)
( -0.61127603, 0.79141748)
IDL> print, exp( complex(0,1)*sqrt(2.)*10. )^sqrt(2.)
( -0.611276, 0.791418)
This seems to suggest that there is a bug in IDL v3.6 which is corrected in the
upcoming IDL v4. (Versions of IDL previous to 3.6 wouldn't have allowed the
above expression.)
Bill Thompson
|
|
|