The Wayback Machine - https://web.archive.org/web/20240118165939/https://www.geeksforgeeks.org/java-math-sinh-method-examples/
Open In App
Related Articles

Java Math sinh() method with Examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The java.lang.Math.sinh() returns the hyperbolic sine of a double value passed to it as argument. The hyperbolic sine of any value a is defined as,

(ea – e-a)/2

where e is Euler’s number.

If the argument is NaN, then the result is NaN. If the argument is infinity then the result will also be infinity with same sign as that of 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 a)
Parameter :
a : the value whose hyperbolic sine is to be returned.

Return :
This method returns the hyperbolic sine value of the argument.

Example 1 : To show working of java.lang.Math.sinh() method.




// Java program to demonstrate working
// of java.lang.Math.sinh() method
import java.lang.Math;
  
class Gfg {
  
    // driver code
    public static void main(String args[])
    {
  
        double a = 3.5;
  
        System.out.println(Math.sinh(a));
  
        a = 90.328;
  
        System.out.println(Math.sinh(a));
    }
}


Output:

16.542627287634996
8.470751974588509E38

Example 2 : To show working of java.lang.Math.sinh() method when argument is NaN or infinity.




// Java program to demonstrate working
// of java.lang.Math.sinh() method infinity case
import java.lang.Math;
  
public class GFG {
      
    // Driver code
    public static void main(String[] args)
    {
  
        double positiveInfinity = 
               Double.POSITIVE_INFINITY;
        double negativeInfinity = 
               Double.NEGATIVE_INFINITY;
        double nan = Double.NaN;
        double result;
  
        // Here argument is negative infinity,
        // output will be negative infinity
        result = Math.sinh(negativeInfinity);
        System.out.println(result);
  
        // Here argument is positive infinity,
        // output will also be positive infinity
        result = Math.sinh(positiveInfinity);
        System.out.println(result);
  
        // Here argument is NaN, output will be NaN
        result = Math.sinh(nan);
        System.out.println(result);
    }
}


Output:

-Infinity
Infinity
NaN

Feeling lost in the vast world of Backend Development? It's time for a change! Join our Java Backend Development - Live Course and embark on an exciting journey to master backend development efficiently and on schedule.
What We Offer:
  • Comprehensive Course
  • Expert Guidance for Efficient Learning
  • Hands-on Experience with Real-world Projects
  • Proven Track Record with 100,000+ Successful Geeks

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 06 Apr, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials