What is Math.sinh() in Java?
Java has a built-in Math class, defined in the java.lang package, which contains important functions to perform basic mathematical operations. The class has the sinh() method, which is used to compute a specified angle’s hyperbolic sine.
Syntax
public static double sinh(double angle);
Parameter
The function takes in one single parameter, which is described below.
anglerepresents the double value corresponding to the angle in randians for which we have to find the hyperbolic sine.
Return value
The function returns the double value corresponding to the hyperbolic sine of the angle.
-
If the value of
angleis , then the value returned isNaN not a number NaN. -
If the value of
angleis positive infinity, then the value returned is positive infinity. -
If the value of
angleis negative infinity, then the value returned is negative infinity.
Code
To convert an angle measured in degrees to an equivalent angle measured in radians, we can use the built-in method
Math.toRadians(double angle_in_degrees).
import java.lang.Math;class HelloWorld {public static void main( String args[] ) {double param = Math.toRadians(30);double result = Math.sinh(param);System.out.println("sinh(" + param + ") = " + result);param = Math.toRadians(45);result = Math.sinh(param);System.out.println("sinh(" + param + ") = " + result);param = Math.toRadians(60);result = Math.sinh(param);System.out.println("sinh(" + param + ") = " + result);param = Math.toRadians(90);result = Math.sinh(param);System.out.println("sinh(" + param + ") = " + result);result = Math.sinh(Double.POSITIVE_INFINITY);System.out.println("sinh(∞) = " + result);result = Math.sinh(Double.NEGATIVE_INFINITY);System.out.println("sinh(-∞) = " + result);result = Math.sinh(Double.NaN);System.out.println("sinh(NaN) = " + result);}}