gamma approximation : what is module cmath and where is it located ?
Terry Reedy
tjreedy at udel.edu
Thu Jul 30 01:35:19 EDT 2009
pdlemper at earthlink.net wrote:
> The following numerical approximation for Euler's Gamma function
> is found in http://en.wikipedia.org/wiki/Lanczos_approximation
>
> from cmath import *
> But I can't figure out where it gets "cmath".
The Python documentation set has a module index. Really handy. I use it
all the time. cmath is under 'c'.
To answer some of your question:
>>> math.sqrt(-1)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
math.sqrt(-1)
ValueError: math domain error
>>> cmath.sqrt(-1)
1j
Which to use depends on the behavior you want.
tjr
More information about the Python-list
mailing list