Java Math.tanh(double x)
Syntax
Math.tanh(double x) has the following syntax.
public static double tanh(double x)
Example
In the following code shows how to use Math.tanh(double x) method.
/*from w w w .j av a 2 s . c o m*/
public class Main {
public static void main(String[] args) {
double x = 45;
double y = -180;
// convert them in radians
x = Math.toRadians(x);
y = Math.toRadians(y);
// print the hyperbolic tangent of these doubles
System.out.println("Math.tanh(" + x + ")=" + Math.tanh(x));
System.out.println("Math.tanh(" + y + ")=" + Math.tanh(y));
}
}
The code above generates the following result.