Python Tutorial Python Advanced Python References Python Libraries

Python cmath - cos() Function

The Python cmath.cos() function returns complex cosine of a complex number z. It is a function on complex plane, and has no branch cuts. Mathematically, it can be expressed as:

complex cos




z Required. Specify the complex number, representing an angle expressed in radians.

Return Value

Returns the complex cosine of z.


In the example below, cos() function is used to find out the complex cosine of the given number.

import cmath

z1 = 2 + 2j
z2 = 2
z3 = 2j

print("cmath.cos(z1):", cmath.cos(z1))
print("cmath.cos(z2):", cmath.cos(z2))
print("cmath.cos(z3):", cmath.cos(z3))

The output of the above code will be:

cmath.cos(z1): (-1.5656258353157435-3.297894836311237j)
cmath.cos(z2): (-0.4161468365471424-0j)
cmath.cos(z3): (3.7621956910836314-0j)

❮ Python cMath Module