The hyperbolic cosine is equivalent to ( (ex + e-x)/2), where e is Euler's number.
The syntax of the cosh() method is:
Math.cosh(double value)
Here, cosh() is a static method. Hence, we are accessing the method using the class name, Math.
cosh() Parameters
The cosh() method takes a single parameter.
- value - angle whose hyperbolic function is to be determined
Note: The value is generally used in radians.
cosh() Return Values
- returns the hyperbolic cosine of value
- returns NaN if the argument value is NaN
- returns 1.0 if the argument is 0
Note: If the argument is infinity, then the method returns positive infinity.
Example 1: Java Math cosh()
In the above example, notice the expression,
Math.cosh(value1)
Here, we have directly used the class name to call the method. It is because cosh() is a static method.
Note: We have used the Java Math.toRadians() method to convert all the values into radians.
Example 2: cosh() Returns NaN and Infinite
In the above example,
- Double.POSITIVE_INFINITY - implements positive infinity in Java
- Double.NEGATIVE_INFINITY - implements negative infinity in Java
- Math.sqrt(-5) - square root of a negative number is not a number
We have used the Java Math.sqrt() method to calculate the square root of a number.
Note: The cosh() method returns positive infinity for both negative and positive infinity arguments.