Java Math tanh() Method

The tanh() method of Java Math class returns the hyperbolic tangent of the specified double value.

Syntax:

public static double tanh(double x)

Parameters:

The parameter ‘x’ represents the number whose hyperbolic tangent is to be determined.

Return Value:

The tanh() method returns the hyperbolic tangent of the argument.

  • It returns zero with same sign as argument, if the argument passed is zero.
  • It returns +1.0, if the argument is positive infinity.
  • It returns -1.0, if the argument is negative infinity.
  • It returns NaN, if the argument is NaN.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Example 5:

Output: