Python math.tanh() Method
Python math.tanh(x) Returns the hyperbolic tangent of x.
Python version: 1.4
Syntax
The syntax of the math.tanh() method is as follows:
math.tanh(x)
Parameter Description:
- x -- required, a positive or negative number. If x is not a number, a TypeError is returned.
Return Value
Returns a floating-point number representing the hyperbolic tangent of a number.
Example
The following example returns the hyperbolic tangent of different numbers:
Example
Import the math package
import
math
Output the hyperbolic tangent values
(
math
.
tanh
(
8
)
)
(
math
.
tanh
(
1
)
)
(
math
.
tanh
(
6.2
)
)
Output result:
0.9999997749296758
0.7615941559557649
-0.9999917628565104
Python math Module