comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Complex exponentiation problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Complex exponentiation problem [message #6213] Fri, 17 May 1996 00:00 Go to next message
brian.jackel is currently offline  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 Go to previous message
asb is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Spherical surface spline code?
Next Topic: 3d surfaces and map projections...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 00:17:37 PDT 2025

Total time taken to generate the page: 0.79828 seconds