Java Math sinh() Method
Java Math Class
Java Math class provides several methods to perform several operations on math calculations like max(), min(), sin(), cos(), round(), ceil(), floor(), abs() etc.
The java.lang.Math class contains various methods for performing basic numeric operations
Here, in the page we will discuss about the math sinh() Method in java.
Java Math sinh() Method :
Returns the hyperbolic sine of a double value. The hyperbolic sine of x is defined to be (ex – e-x)/2 where e is Euler’s number.
Special Points :
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is an infinity with the same sign as the argument.
- If the argument is zero, then the result is a zero with the same sign as the argument.
Syntax :
public static double sinh(double x)
Parameters :
x - The number whose hyperbolic sine is to be returned.
Throws Exception :
It does throws any exceptions and error.
Return Value :
The hyperbolic sine of x.
Example 1 :
public class Main{ public static void main(String[] args) {
double x = 1.0; // value for which to calculate hyperbolic sine
double sinh = Math.sinh(x); // calculate hyperbolic sine of x
System.out.println("Hyperbolic sine of 1.0: " + sinh); } }
Output :
Hyperbolic sine of 1.0: 1.1752011936438014
Explanation :
In this example, we pass the value 1.0 to the sinh() method, which calculates and returns the hyperbolic sine of 1.0. Finally, we print the result to the console.
Example 2 :
Run
public class Main { public static void main(String[] args) { // case: argument is NaN double value = Double.NaN; double sinh = Math.sinh(value); System.out.println("Hyperbolic sine of " + value + ": " + sinh); // output: NaN // case: argument is infinite value = Double.POSITIVE_INFINITY; sinh = Math.sinh(value); System.out.println("Hyperbolic sine of " + value + ": " + sinh); // output: Infinity value = Double.NEGATIVE_INFINITY; sinh = Math.sinh(value); System.out.println("Hyperbolic sine of " + value + ": " + sinh); // output: -Infinity // case: argument is zero value = 0.0; sinh = Math.sinh(value); System.out.println("Hyperbolic sine of " + value + ": " + sinh); // output: 0.0 } }
Output :
Hyperbolic sine of NaN: NaN Hyperbolic sine of Infinity: Infinity Hyperbolic sine of -Infinity: -Infinity Hyperbolic sine of 0.0: 0.0
Explanation :
In this example, we use the Double class to represent special values such as NaN (not a number) and Infinity. We then pass these special values as arguments to the sinh() method and print the result to the console.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment