Java Tutorial Java Advanced Java References

Java Math - cosh() Method



The Java cosh() method returns hyperbolic cosine of a value. The hyperbolic cosine of x is defined as:

cosh

where e is an Euler's number.

In special cases it returns the following:

  • If the argument is NaN, then the result is NaN.
  • If the argument is infinite, then the result is positive infinity.
  • If the argument is zero, then the result is 1.0.

Syntax

public static double cosh(double arg)

Parameters

arg Specify the value.

Return Value

Returns the hyperbolic cosine of a value.

Exception

NA.

Example:

In the example below, cosh() method is used to find out the hyperbolic cosine of a value.

public class MyClass {
 public static void main(String[] args) {
  System.out.println(Math.cosh(0));   
  System.out.println(Math.cosh(2));
  System.out.println(Math.cosh(4));     
 }
}

The output of the above code will be:

1.0
3.7621956910836314
27.308232836016487

❮ Java Math Methods

5