Home » Java programming language

Java StrictMath sinh() Method with Example

StrictMath Class sinh() method: Here, we are going to learn about the sinh() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on December 27, 2019

StrictMath Class sinh() method

  • sinh() method is available in java.lang package.
  • sinh() method is used to return the hyperbolic sine of an angle of the given parameter in the method. Here, "sinh" stands for hyperbolic sine of an angle.
  • sinh() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
  • In sinh() method we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of StrictMath class then after we will pass the same variable in sinh() method).
  • sinh() method does not throw any exception at the time of returning hyperbolic sine of an angle.

Syntax:

    public static double sinh(double d);

Parameter(s):

  • double d – represents the value whose hyperbolic sine of an angle is to be returned.

Return value:

The return type of this method is double – it returns the hyperbolic sine value of the given argument.

Note:

  • If we pass NaN, the method returns NaN.
  • If we pass an infinity (positive or negative), the method returns the same value.
  • If we pass a zero (positive or negative), the method returns the 0.0.

Example:

// Java program to demonstrate the example of  
// sinh(double d) method of StrictMath class.

public class Sinh {
    public static void main(String[] args) {
        // variable declaration
        double d1 = 7.0 / 0.0;
        double d2 = -7.0 / 0.0;
        double d3 = 0.0;
        double d4 = -0.0;
        double d5 = 60.0;

        // Display previous value of d1,d2,d3,d4 and d5
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);
        System.out.println("d3: " + d3);
        System.out.println("d4: " + d4);
        System.out.println("d5: " + d5);

        // By using toRadians() method to convert 
        // absolute value into radians.
        d1 = StrictMath.toRadians(d1);
        d2 = StrictMath.toRadians(d2);
        d3 = StrictMath.toRadians(d3);
        d4 = StrictMath.toRadians(d4);
        d5 = StrictMath.toRadians(d5);

        // Here , we will get (infinity) because we are 
        // passing parameter whose value is (7.0/0.0)
        System.out.println("StrictMath.sinh(d1): " + StrictMath.sinh(d1));

        // Here , we will get (-infinity) because we are 
        // passing parameter whose value is (-7.0/0.0)
        System.out.println("StrictMath.sinh(d2): " + StrictMath.sinh(d2));

        // Here , we will get (0.0) because we are passing 
        // parameter whose value is (0.0)
        System.out.println("StrictMath.sinh(d3): " + StrictMath.sinh(d3));

        // Here , we will get (-0.0) because we are passing 
        // parameter whose value is (-0.0)
        System.out.println("StrictMath.sinh(d4): " + StrictMath.sinh(d4));

        // Here we will find hyperbolic sine of d5 by using sinh() method
        System.out.println("StrictMath.sinh(d5): " + StrictMath.sinh(d5));
    }
}

Output

d1: Infinity
d2: -Infinity
d3: 0.0
d4: -0.0
d5: 60.0
StrictMath.sinh(d1): Infinity
StrictMath.sinh(d2): -Infinity
StrictMath.sinh(d3): 0.0
StrictMath.sinh(d4): -0.0
StrictMath.sinh(d5): 1.2493670505239751


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.