StrictMath tanh() Method in Java
The java.lang.StrictMath.tanh() method is used to return the hyperbolic tan of a double value passed as parameter to the function. The hyperbolic tan of x is defined by the formula where e denotes the Euler’s number.
public static double tanh(double x)
Parameters: The function accepts a single parameter x of double type and refers to the value whose hyperbolic tangent equivalence is to be returned.
Return Values: This method returns a double value which is the hyperbolic tangent of x. The absolute value of exact tanh never exceeds 1. The following cases are considered:
- The function returns NaN if the argument is NaN.
- The function returns +1.0 and -1.0 for positive infinity and negative infinity respectively.
- The function returns zero with the same sign as the argument if the argument is zero
Input: 0.7853981633974483 Output: 0.6557942026326724 Input: 4.0 Output: 0.999329299739067
Below programs illustrate the java.lang.StrictMath.tanh() method:
Hyperbolic tan of 0.7853981633974483 = 0.6557942026326724
Hyperbolic tan of Infinity = 1.0 Hyperbolic tan of 0.0 = 0.0
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.