Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python cmath.tan() function returns complex tangent of a complex number z. It is a function on complex plane, and has no branch cuts. It is periodic with respect to the real component, with period 𝜋i, and has poles of the first order along the real line, at coordinates (𝜋(1/2 + n), 0). However no common floating-point representation is able to represent 𝜋/2 exactly.

Mathematically, it can be expressed as:

complex tan

Syntax

cmath.tan(z)

Parameters

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

Return Value

Returns the complex tangent of z.

Example:

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

import cmath

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

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

The output of the above code will be:

cmath.tan(z1): (-0.028392952868232294+1.0238355945704727j)
cmath.tan(z2): (-2.185039863261519+0j)
cmath.tan(z3): 0.9640275800758169j

❮ Python cMath Module

5