Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

math
java
communitycreator
math.sinh()

What is Math.sinh() in Java?

Tarun Telang

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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.

  • angle represents 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 angle is NaNnot a number, then the value returned 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.

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);
}
}
Example code for Math.sinh() in Java

RELATED TAGS

math
java
communitycreator
math.sinh()

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring