Java.lang Package Classes

Java Math - cosh() Method



The java.lang.Math.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 x)

Parameters

x Specify the number whose hyperbolic cosine is to be returned.

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 the given values.

import java.lang.*;

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.lang - Math