Complex math
Syntax
 cmath.rect(AbsoluteValue, Phase)
Advanced complex arithmetic
The module cmath
includes additional functions to use complex numbers.
This module can calculate the phase of a complex number, in radians:
It allows the conversion between the cartesian (rectangular) and polar representations of complex numbers:
The module contains the complex version of

Exponential and logarithmic functions (as usual,
log
is the natural logarithm andlog10
the decimal logarithm):

Square roots:

Trigonometric functions and their inverses:

Hyperbolic functions and their inverses:
Basic complex arithmetic
Python has builtin support for complex arithmetic. The imaginary unit is denoted by j
:
Complex numbers can be summed, subtracted, multiplied, divided and exponentiated:
Python can also extract the real and imaginary parts of complex numbers, and calculate their absolute value and conjugate: