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.
public static double sinh(double angle);
The function takes in one single parameter, which is described below.
angle
represents the double value corresponding to the angle in randians for which we have to find the hyperbolic sine.The function returns the double value corresponding to the hyperbolic sine of the angle
.
If the value of angle
is NaN
.
If the value of angle
is positive infinity, then the value returned is positive infinity.
If the value of angle
is negative infinity, then the value returned is negative infinity.
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);}}