The math.tanh()  Function returns the hyperbolic tangent of x, where x is the input parameter. 

Syntax:
math.tanh(x)
copy

Where  x is the numeric value whose hyperbolic tangent we want .

ExampleEdit & Run
import math

print(math.tanh(0))
print(math.tanh(math.pi / 2)) 
print(math.tanh(-math.pi))
copy
Output:
0.0 0.9171523356672744 -0.99627207622075 [Finished in 0.01041463017463684s]

The math.tanh() function  is commonly used in machine learning and neural networks. It is used to calculate the activation function for neurons, as well as to calculate the gradient of the neural network.