math.exp(complex)
David Eppstein
eppstein at ics.uci.edu
Sun Sep 21 23:58:11 CEST 2003
In article <mailman.1064176468.3210.python-list at python.org>,
"Tim Peters" <tim.one at comcast.net> wrote:
> > >>> math.e**(1j*math.pi) (-1+1.2246467991473532e-16j)
>
> Or, in this case, use the builtin pow(), which looks for a __pow__ method,
> which is the same thing "**" does. Math libraries in general can return a
> better result for exp(x) than e**x, though, since the latter form uses a
> machine approximation to e as the base.
Doesn't look especially different to me, for the numbers I'm currently
interested in applying this to (small pure imaginary):
>>> from cmath import *
>>> exp(1j*pi)
(-1+1.2246467991473532e-16j)
>>> e**(1j*pi)
(-1+1.2246467991473532e-16j)
--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
More information about the Python-list
mailing list