Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.tanh() Method

Python math.tanh() Method

Python math Module Python math Module

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:

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

print

(

math

.

tanh

(

8

)

)

print

(

math

.

tanh

(

1

)

)

print

(

math

.

tanh

(

6.2

)

)

Output result:


0.9999997749296758
0.7615941559557649
-0.9999917628565104

Python math Module Python math Module