The java.lang.Math.tanh() returns the hyperbolic tangent of a double value passed to it as argument. The hyperbolic tangent of any value a is defined as,
((ea – e-a)/2)/((ea + e-a)/2)
where e is Euler’s number. In other words, we can say that tanh(a) = sinh(a)/cosh(a).
If the argument is NaN, then the result is NaN. If the argument is positive infinity then the result will be +1.0. If the argument is negative infinity then the result will be -1.0. If the argument is zero, then the result is zero with the same sign as that of the argument a.
public static double tanh(double a) Parameter : a : the value whose hyperbolic tangent is to be returned.
This method returns the hyperbolic tangent value of the argument.
Example 1 : To show working of java.lang.Math.tanh() method.
0.9981778976111987 1.0 0.0
Example 2 : To show working of java.lang.Math.tanh() method when argument is NaN or infinity.
-1.0 1.0 NaN
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.