gamma approximation : what is module cmath and where is it located ?

Terry Reedy tjreedy at
Thu Jul 30 01:35:19 EDT 2009

pdlemper at wrote:
> The following numerical approximation for Euler's Gamma function
> is found in
> 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>
ValueError: math domain error
 >>> cmath.sqrt(-1)

Which to use depends on the behavior you want.


More information about the Python-list mailing list