Complex exponentiation problem [message #6213] |
Fri, 17 May 1996 00:00  |
brian.jackel
Messages: 23 Registered: May 1996
|
Junior Member |
|
|
There appears to be something wrong when using the "^"
operator on complex numbers under certain conditions. If
anyone could shed some light on this it would be greatly
appreciated. I can avoid the problem for now by using only
integer exponents, but it would be nice if I could get the
general case to work as expected.
Here's a code fragment which shows the problem:
;----------------------------------------------------------- -------------------
;create a complex number, print it ou
IDL> w= EXP( -COMPLEX(0.0,1.0)*(2.0*!pi)/n)
IDL> print,w
( 0.923880, -0.382683)
;raise it to a variety of integer powers, everything okay
IDL> print,w^[1,2,3]
( 0.923880, -0.382683)( 0.707107, -0.707107)( 0.382683, -0.923880)
;raise it to the same powers, but floating point. Not okay
IDL> print,w^[1.0,2.0,3.0]
( 0.857090, 0.000000)( 0.857090, 0.000000)( 0.857090, 0.000000)
;Done individually, everything works
IDL> print,w^1.0
( 0.923880, -0.382683)
IDL> print,w^2.0
( 0.707107, -0.707107)
IDL> print,w^3.0
( 0.382683, -0.923880)
;----------------------------------------------------------- -------------------
This happens for { alpha vms vms 4.0.1} and { x86 Win32 Windows 4.0.1}.
Why?
Brian Jackel
University of Western Ontario
|
|
|
Re: Complex exponentiation problem [message #6260 is a reply to message #6213] |
Tue, 28 May 1996 00:00  |
asb
Messages: 13 Registered: May 1994
|
Junior Member |
|
|
It also works correctly if the exponent is a complex array:
IDL> w= EXP( -COMPLEX(0.0,1.0)*(2.0*!pi)/16)
IDL> print,w
( 0.923880, -0.382683)
IDL> p=[1,2,3]
IDL> print,w^p
( 0.923880, -0.382683)( 0.707107, -0.707107)
( 0.382683, -0.923880)
IDL> p=1.0*p
IDL> print,w^p
( 0.857090, -0.00000)( 0.857090, -0.00000)
( 0.857090, -0.00000)IDL> w= EXP( -COMPLEX(0.0,1.0)*(2.0*!pi)/16)
IDL> print,w
( 0.923880, -0.382683)
IDL> p=[1,2,3]
IDL> print,w^p
( 0.923880, -0.382683)( 0.707107, -0.707107)
( 0.382683, -0.923880)
IDL> p=1.0*p
IDL> print,w^p
( 0.857090, -0.00000)( 0.857090, -0.00000)
( 0.857090, -0.00000)
IDL> p=complex(1.,0.)*p
IDL> print,w^p
( 0.923880, -0.382683)( 0.707107, -0.707107)
( 0.382683, -0.923880)
IDL> p=complex(1.,0.)*p
IDL> print,w^p
( 0.923880, -0.382683)( 0.707107, -0.707107)
( 0.382683, -0.923880)
Truly bizarre.
Alan
|
|
|