Javatpoint Logo
Javatpoint Logo

Java Math.tanh() method

The java.lang.Math.tanh() is used to return the hyperbolic tangent of a value. The hyperbolic tangent of any value x can be defined as ((ex - e -x)/2) / ((ex + e -x)/2), where e is an Euler's number. We can say that tanh(a) = sinh(a)/cosh(a).

Syntax

Parameter

Return

  • If the argument is positive or negative number, this method will return hyperbolic tangent value.
  • If the argument is Zero, this method will return zero with the same sign as the argument.
  • If the argument is NaN, this method will return NaN.
  • If the argument is Positive Infinity, this method will return +1.0.
  • If the argument is Negative Infinity, this method will return -1.0.

Example 1

Test it Now

Output:

0.9999999999244973

Example 2

Test it Now

Output:

1.0

Example 3

Test it Now

Output:

-0.0

Example 4

Test it Now

Output:

NaN

Example 5

Test it Now

Output:

-1.0

Next TopicJava Math





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA