Python cMath Module With Examples

In-Built methods of cmath module:

This module provides the different types of mathematical functions to perform the mathematical operation. cmath module is used to solve the complex number problems. There are lots of functions present in this module and all are discussed below:

S.No Math module Description
1 cmath.isclose(a,b)  This function is used to return Boolean values. It returns true if the values of a and b are close to each other and it returns false in other cases.
2 cmath.isfinite(n)  This function returns True if n value neither infinity nor a NaN and it returns false in other cases.
3 cmath.isinf(n)  It returns True if the value of x is positive or negative infinity and it returns False in other cases.
4 cmath.isnan(n) It returns boolean True value if the value of x is not a number and it returns false in other cases.
5 cmath.exp(n)  It returns the value of base e raised to the power n, where the value of e is 2.7182.
6 cmath.log(n[,base])  This function returns the natural logarithm of n with one argument.
7 cmath.log10(x)  It returns the logarithmic value of x with base 10.
8 cmath.sqrt(n)  It returns the square root value of n,
9 cmath.acos(n)  It returns the arc cosine value of n.
10 cmath.asin(n)  It returns the arc sine value of n.
11 cmath.tan(n)  It returns the arc tangent of x.
12 cmath.cos(n)  It returns the cosine value of n. 
13 cmath.sin(n)  It returns the sine of n.
14 cmath.tan(n)  It returns the tangent value of n.
15 cmath.acosh(n)  This function returns the inverse hyperbolic cosine value of n.
16 cmath.asinh(n)  It returns the inverse hyperbolic sine value of n.
17 cmath.atanh(n)  It returns the inverse hyperbolic tangent value of n.
18 cmath.cosh(n)  It returns the hyperbolic cosine value of n.
19 cmath.sinh(n)  It returns the hyperbolic sine of n.
20 cmath.tanh(n)  This function returns the hyperbolic tangent of n.
21 cmath.phase(n)  It returns the argument, of a complex.
22 cmath.polar(n)  This function converts a complex number to polar coordinates.
23 cmath.rect(n, phi)  This function converts polar coordinates to rectangular coordinates and returns a complex. 
24 cmath.pi(n)  This function consists of the mathematical constant value of pi = 3.141.
25 cmath.e(n)  This function consists of the mathematical constant value of e = 2.718.
26 cmath.tau  This function consists of the mathematical constant value of tau = 6.283.
27 cmath.inf  It represents a floating-point positive infinity.
28 cmath.nan  It represents floating-point not a number value.