Search notes:

Python library math vs cmath

The math module consists mostly of thin wrappers around the platform C math library functions.
cmath provides a similar, but not identical, selection of functions which always return complex numbers (but constants such as e, pi or tau are floats):
>>> import cmath
>>> cmath.sqrt(4)
(2+0j)
>>> cmath.e
2.718281828459045
With math, sqrt(-1) raises ValueError while cmath returns i (1j) for this expression.

Index