# Java sinh Function

The Java sinh Function is one of the Math functions, which is to calculate the Trigonometric Hyperbolic Sine for the specified expression.

## Java sinh Function syntax

The basic syntax of the Math.sinh in Java Programming language is as shown below.

```static double sinh(double number); //Return Type is Double

// In order to use in program:
Math.sinh(double number);```

Number: It can be a number or a valid numerical expression for which you want to find a hyperbolic Sine value.

• If the number argument is a positive or negative number, the Java Math.sinh function will return the hyperbolic Sine value.
• If the number argument is zero, the Math.sinh function will return zero with the same sign.
• When the number argument infinity, the Java Math.sinh function will return the result as Infinity with the same sign.
• If it is not a number, Math.sinh function will return NaN.

NOTE: The hyperbolic sine of x is defined as (e^x – e^-x)/2, where is Euler’s Number E.

## Java sinh Function Example

In this example, we use the Java Math.sinh Function to find the hyperbolic Sine values of both positive and negative values and display the output.

TIP: Please refer to the sin Function Function article to understand the Java Sine Function.

```package TrigonometricFunctions;

public class SinhMethod {
public static void main(String[] args) {
double x = Math.sinh(10.65 - 13.95 + 4.38);
System.out.println("Hyperbolic Sine value =  " + x);

System.out.println("\nHyperbolic Sine value of Positive Value = " + Math.sinh(4.25));
System.out.println("Hyperbolic Sine value of Positive Value =  " + Math.sinh(7.28));

System.out.println("\nHyperbolic Sine value of Negative Value =  " + Math.sinh(-2.85));
System.out.println("Hyperbolic Sine value of Negative Value =  " + Math.sinh(-0.95));

System.out.println("\nHyperbolic Sine value of Negative Value = " + Math.sinh(m));
}
}```

Within this Java Sinh function example, we declared variable x of type Double. Next, we used the Math.sinh function directly on expression. Here, we used System.out.println statement to print the result as output.

```double x = Math.sinh(10.65 - 13.95 + 4.38);
System.out.println("Hyperbolic Sine value =  " + x);```

Next, We used the Math.sinh Function directly on Positive double values.

```System.out.println("\nHyperbolic Sine value of Positive Value = " + Math.sinh(4.25));
System.out.println("Hyperbolic Sine value of Positive Value =  " + Math.sinh(7.28));```

Next, We used the Function directly on Negative double values.

```System.out.println("\nHyperbolic Sine value of Negative Value =  " + Math.sinh(-2.85));
System.out.println("Hyperbolic Sine value of Negative Value =  " + Math.sinh(-0.95));```

Here, We declared a variable of type Double and assigned the value. Next, we used the Math.toRadians function to convert 45 into equivalent radiant. Then the System.out.println statement prints the result as output.

```double m = Math.toRadians(45);
System.out.println("\nHyperbolic Sine value of Negative Value = " + Math.sinh(m));```

## Java sinh on Array example

In this Java program, we find the Hyperbolic Sine values of bulk data. Here, we are going to declare an array of double type and find the Hyperbolic Sine values of array elements.

```package TrigonometricFunctions;

public class SinhMethodOnArrays {
public static void main(String[] args) {

double [] myArray = {0, 1, 0.30, 0.45, 0.60, 0.75, -0.90, -0.920, -1.98, -6.48};

for (int i = 0; i < myArray.length; i++) {
System.out.format("Hyperbolic Sine of Array Element %.2f = %.4f\n", myArray[i], Math.sinh(myArray[i]));
}
}
}```
``````Hyperbolic Sine of Array Element 0.00 = 0.0000
Hyperbolic Sine of Array Element 1.00 = 1.1752
Hyperbolic Sine of Array Element 0.30 = 0.3045
Hyperbolic Sine of Array Element 0.45 = 0.4653
Hyperbolic Sine of Array Element 0.60 = 0.6367
Hyperbolic Sine of Array Element 0.75 = 0.8223
Hyperbolic Sine of Array Element -0.90 = -1.0265
Hyperbolic Sine of Array Element -0.92 = -1.0554
Hyperbolic Sine of Array Element -1.98 = -3.5523
Hyperbolic Sine of Array Element -6.48 = -325.9847``````

We used For Loop to iterate the Array. Within the sinh For Loop, we initialized the i value as 0. Next, the compiler will check for the condition (i < myArray.length). myArray.length finds the length of an array.

`for (int i = 0; i < myArray.length; i++) {`

The following statements will print the output. If you observe the code snippet, we used the sinh Math function directly inside the System.out.format statement. Here, the compiler will call the Java Math.sinh method (static double sinh(double number) ) to find the corresponding Sine values.

`System.out.format("Hyperbolic Sine of Array Element %.2f = %.4f\n", myArray[i], Math.sinh(myArray[i]));`

NOTE: To find the hyperbolic Sine value of a single item, then use: Math.sinh(myArray[index_position])

## Java sinh Function on Arraylist example

In this Java program, we are going to declare an ArrayList of double type and find the hyperbolic Sine values of list elements.

```package TrigonometricFunctions;

import java.util.ArrayList;

public class SinhMethodOnArrayList {
public static void main(String[] args) {

ArrayList<Double> myList = new ArrayList<Double>(5);

for (double x : myList) {
System.out.format("Hyperbolic Sine value of ArrayList Item %.2f =  %.4f \n", x, Math.sinh(x));
}
}
}```
``````Hyperbolic Sine value of ArrayList Item 2.45 =  5.7510
Hyperbolic Sine value of ArrayList Item 9.49 =  6613.3976
Hyperbolic Sine value of ArrayList Item -15.60 =  -2978269.0066
Hyperbolic Sine value of ArrayList Item -0.75 =  -0.8223
Hyperbolic Sine value of ArrayList Item 5.48 =  119.9213
Hyperbolic Sine value of ArrayList Item -5.48 =  -119.9213 ``````

We used the For Loop to iterate the double values in ArrayList

`for (double x : myList) {`

Here, the compiler will call the math sinh method ( static double sinh(double x) ) to find the corresponding sine values and print the output.

`System.out.format("Hyperbolic Sine value of ArrayList Item %.2f =  %.4f \n", x, Math.sinh(x));`
Back To Categories Java