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


The Python cmath.tanh() function is used to return hyperbolic tangent of a complex number. The hyperbolic tangent of x is defined as:

tanh

where e is an Euler's number.

Syntax

cmath.tanh(x)

Parameters

x Required. Specify a number to find the hyperbolic tangent of

Return Value

Returns the hyperbolic tangent of x.

Example:

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

import cmath

x = 2 + 2j
y = 2
z = 2j

print(cmath.tanh(x))
print(cmath.tanh(y))
print(cmath.tanh(z))

The output of the above code will be:

(1.0238355945704727-0.028392952868232294j)
(0.9640275800758169+0j)
-2.185039863261519j

❮ Python cMath Module