Home >>Python math Module >Python math.tanh() Method

Python math.tanh() Method

Python math.tanh() Method

Python math.tanh() method in python is used to returns hyperbolic tangent of a given number and it accepts a number.

Syntax:
math.tanh(x)

Parameter Values

Parameter Description
x It is required parameter and is used to find the hyperbolic tangent of a given number
Here is an Example of Python math.tanh() Method:

import math
print(math.tanh(5))
print(math.tanh(4))
print(math.tanh(-8.4))

Output:
0.9999092042625951
0.999329299739067
-0.9999998988693781
Example 2:

import math 
x = 5
print("math.tanh(",x,"): ", math.tanh(x))
x = 4.7
print("math.tanh(",x,"): ", math.tanh(x))
x = 1.36
print("math.tanh(",x,"): ", math.tanh(x))
x = 0
print("math.tanh(",x,"): ", math.tanh(x))
x = 12.32
print("math.tanh(",x,"): ", math.tanh(x))

Output:
math.tanh( 5 ): 0.9999092042625951
math.tanh( 4.7 ): 0.9998345655542966
math.tanh( 1.36 ): 0.8763930674728229
math.tanh( 0 ): 0.0
math.tanh( 12.32 ): 0.999999999960188