ExampleEdit & Run
#import the cmath module
import cmath

#print the hyperbolic tangent of a radian angle
print(cmath.tanh(0.536j))
Output:
0.5940053366525064j [Finished in 0.010579618159681559s]

The cmath.tanh() function calculates the hyperbolic tangent of a complex number given in radians.

Syntax:
cmath.tanh(x)
x The radian complex angle whose hyperbolic tangent is to be calculated. The value should be numerical value, either real or complex. If the value is a real number, it is first converted into a complex value before the operation.

The function returns a complex number representing the hyperbolic tangent of the input complex value, x

ExampleEdit & Run
import cmath

print(cmath.tanh(0))
print(cmath.tanh(0.5 + 1j))
print(cmath.tanh(-2j))
print(cmath.tanh(0.23 + 1.24j))
Output:
0j (1.0428307283443612+0.8068774121630852j) (-0+2.185039863261519j) (1.4949761129394896+1.9279684139502395j) [Finished in 0.010480435099452734s]