The java.lang.Math.cosh() returns the hyperbolic cosine of a double value passed to it as argument. The hyperbolic cosine of any value a is defined as,
(ea + e-a)/2
where e is Euler’s number.
If the argument is NaN, then the result is NaN. If the argument is infinity then the result will be positive infinity. If the argument is zero, then the result is one.
Syntax :
public static double cosh(double a) Parameter : a : the value whose hyperbolic cosine is to be returned.
Return :
This method returns the hyperbolic cosine value of the argument.
Example 1 : To show working of java.lang.Math.cosh() method.
// Java program to demonstrate working // of java.lang.Math.cosh() method import java.lang.Math; class Gfg { // driver code public static void main(String args[]) { double a = 3.5; System.out.println(Math.cosh(a)); a = 90.328; System.out.println(Math.cosh(a)); } } |
16.572824671057315 8.470751974588509E38
Example 2 : To show working of java.lang.Math.cosh() method when argument is NaN or infinity.
// Java program to demonstrate working // of java.lang.Math.cosh() method infinity case import java.lang.Math; public class GFG { public static void main(String[] args) { double positiveInfinity = Double.POSITIVE_INFINITY; double negativeInfinity = Double.NEGATIVE_INFINITY; double nan = Double.NaN; double result; // Here argument is negative infinity result = Math.cosh(negativeInfinity); System.out.println(result); // Here argument is positive infinity result = Math.cosh(positiveInfinity); System.out.println(result); // Here argument is NaN, output will be NaN result = Math.cosh(nan); System.out.println(result); } } |
Infinity Infinity NaN
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- StrictMath cosh() Method in Java
- Java Math random() method with Examples
- Java Math min() method with Examples
- Java Math max() method with Examples
- Java Math abs() method with Examples
- Java Math acos() method with Examples
- Java Math sin() method with Examples
- Java Math sinh() method with Examples
- Java Math tanh() method with Examples
- Java Math cos() method with Examples
- Java Math tan() method with Examples
- Java Math copySign() method with Examples
- Java Math IEEEremainder() method with Examples
- Java Math nextDown() method with Examples
- Java Math nextUp() method with Examples
- Java Math ulp() method with Examples
- Math fma() method in Java with Examples
- Math multiplyHigh() method in Java with Examples
- Math multiplyFull() method in Java with Examples
- Java.math.BigInteger.modInverse() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

