Python cmath Module


Python cmath Module

Python has a built-in module that you can use for mathematical tasks for complex numbers.

The methods in this module accepts int, float, and complex numbers. It even accepts Python objects that has a __complex__() or __float__() method.

The methods in this module almost always return a complex number. If the return value can be expressed as a real number, the return value has an imaginary part of 0.

The cmath module has a set of methods and constants.


cMath Methods

Method Description
Returns the arc cosine value of x
Returns the hyperbolic arc cosine of x
Returns the arc sine of x
Returns the hyperbolic arc sine of x
Returns the arc tangent value of x
Returns the hyperbolic arctangent value of x
Returns the cosine of x
Returns the hyperbolic cosine of x
Returns the value of Ex, where E is Euler's number (approximately 2.718281...), and x is the number passed to it
Checks whether two values are close, or not
Checks whether x is a finite number
Check whether x is a positive or negative infinty
Checks whether x is NaN (not a number)
Returns the logarithm of x to the base
Returns the base-10 logarithm of x
Return the phase of a complex number
Convert a complex number to polar coordinates
Convert polar coordinates to rectangular form
Returns the sine of x
Returns the hyperbolic sine of x
Returns the square root of x
Returns the tangent of x
Returns the hyperbolic tangent of x

cMath Constants

Constant Description
Returns Euler's number (2.7182...)
Returns a floating-point positive infinity value
Returns a complex infinity value
Returns floating-point NaN (Not a Number) value
Returns coplext NaN (Not a Number) value
Returns PI (3.1415...)
Returns tau (6.2831...)


Login
ADS CODE