Home >>Java Math Methods >Java Math.tanh() method

Java Math.tanh() method

Java Math.tanh() method

Java Math.tanh() method in Java Math is used to return a value with the hyperbolic tangent. It is possible to define the hyperbolic tangent of any value x as ((ex-e -x)/2)/(((ex + e -x)/2), where e is the number of Euler. We might say the tanh(a) = sinh(a)/cosh(a).

Syntax

public static double tanh(double x) 

Parameter

x = This parameter is used to the number whose hyperbolic tangent is to be returned.

Return

It is used to returns the hyperbolic tangent of x.

Java Math.tanh() method Example 1


public class MyClass  
{  
public static void main(String[] args)   
{  
double x = 7.0;  
System.out.println(Math.tanh(x));  
}  
}  

Output:
0.9999983369439447

Java Math.tanh() method Example 2


public class MyClass 
{  
public static void main(String[] args)   
{  
double x = 45.0;  
System.out.println(Math.tanh(x));  
}  
}  

Output:
1.0

No Sidebar ads