Java Math sinh()

sinh() accepts a double value as an argument and returns hyperbolic sine of the argument. The returned value is of type double.

Following is the syntax of sinh() method.

</>
Copy
double value = sinh(double x)

Since the definition of sinh() function has double datatype as argument, you can pass int, float or long as arguments; because these datatypes could implicitly promote to double.

We shall learn about some of the special cases for sinh() method with examples.

Example 1 – Math.sinh(double)

In the following example, we pass angle in radians as argument to sinh() method and find its value.

Java Program

</>
Copy
public class MathExample {
	public static void main(String[] args) {
		double x = 10;
		double result = Math.sinh(x);
		System.out.println(result);
	}
}

Output

11013.232874703393

Example 2 – Math.sinh(int)

In the following example, we pass an int value for the argument to sinh() method.

Java Program

</>
Copy
public class MathExample {
	public static void main(String[] args) {
		int x = 5;
		double result = Math.sinh(x);
		System.out.println(result);
	}
}

Output

74.20321057778875

Similarly, you can provide a float or long value as argument to sinh() method.

Example 3 – Math.sinh(NaN)

In the following example, we pass Double.NaN as argument to sinh() method. As per the definition of the sin() in Math class, the method should return NaN value.

Java Program

</>
Copy
public class MathExample {
	public static void main(String[] args) {
		double x = Double.NaN;
		double result = Math.sinh(x);
		System.out.println(result);
	}
}

Output

NaN

Example 4 – Math.sinh() – With Positive Infinity as Argument

In the following example, we pass Double.POSITIVE_INFINITY as argument to sinh() method. As per the definition of the sinh() method in Math class, sinh() should return Infinity value with same sign as that of argument.

Java Program

</>
Copy
public class MathExample {
	public static void main(String[] args) {
		double x = Double.POSITIVE_INFINITY;
		double result = Math.sinh(x);
		System.out.println(result);
	}
}

Output

Infinity

Example 5 – Math.sinh() – With Negative Infinity as Argument

In the following example, we pass Double.POSITIVE_INFINITY as argument to sinh() method. As per the definition of the sinh() method in Math class, sinh() should return Infinity value with same sign as that of argument.

Java Program

</>
Copy
public class MathExample {
	public static void main(String[] args) {
		double x = Double.NEGATIVE_INFINITY;
		double result = Math.sinh(x);
		System.out.println(result);
	}
}

Output

-Infinity

Conclusion

In this Java Tutorial, we learned about Java Math.sinh() function, with example programs.