cmath – mathematical functions for complex numbers

This module implements a subset of the corresponding CPython module, as described below. For more information, please refer to the original CPython documentation: cmath.

The cmath module provides some basic mathematical functions for dealing with complex numbers.

Function

cos

cmath.cos(z)

Returns the cosine of z.

exp

cmath.exp(z)

Returns the exponent of z.

log

cmath.log(z)

Returns the natural logarithm of z. The branch cuts along the negative real axis.

log10

cmath.log10(z)

Returns the base 10 logarithm of z. The branch cuts along the negative real axis.

phase

cmath.phase(z)

Returns the phase, range (-pi, +pi) of the number "z".

polar

cmath.polar(z)

Return the polar form of z as a tuple.

rect

cmath.rect(r, phi)

Returns the complex number of the modulus r and the phase phi.

sin

cmath.sin(z)

Returns the sine of z.

sqrt

cmath.sqrt(z)

Returns the square root of z.

Constants

cmath.e

The basis of natural logarithm

cmath.pi

Ratio of circumference to diameter