Get the hyperbolic cosine of a given value in Java

Java 8Object Oriented ProgrammingProgramming

In order to get the hyperbolic cosine of a given value in Java,we use the java.lang.Math.cosh() method. The cosh() method accepts an argument in radians and returns the hyperbolic cosine of the argument which acts as the angle.

Declaration − - The java.lang.Math.cosh() is declared as follows −

public static double cosh(double x)

where x is the angle in radians.

Let us see a program to get the hyperbolic cosine of a given value in Java.


 Live Demo

import java.lang.Math;
public class Example {
   public static void main(String[] args) {
      // get two double numbers in degrees
      double x = 90;
      double y = 180;
      // convert them in radians
      x = Math.toRadians(x);
      y = Math.toRadians(y);
      // computing and displaying the hyperbolic cosine of these doubles
      System.out.println("Hyperbolic cosine of " + x + " = " + Math.cosh(x));
      System.out.println("Hyperbolic cosine of " + y + " = " + Math.cosh(y));


Hyperbolic cosine of 1.5707963267948966 = 2.5091784786580567
Hyperbolic cosine of 3.141592653589793 = 11.591953275521519
Published on 07-Jan-2019 11:47:36