StrictMath cosh() Method in Java
Last Updated :
31 Dec, 2021
The java.lang.StrictMath.cosh() is an inbuilt method in Java which returns the hyperbolic cosine value of a given double argument.
- The method returns NaN when the argument is NaN.
- The method returns a positive infinity when the argument is infinity.
- The method returns 1.0 when the given argument is 0.0.
Syntax :
public static double cosh(double num)
Parameters: The method accepts one parameter num of double type whose hyperbolic cosine value is to be returned.
Return Value : The method returns the hyperbolic cosine value of num.
Examples :
Input: num = 60.0
Output: 5.710036949078421E25
Input: num = 0.0
Output: 1.0
Below programs illustrate the java.lang.StrictMath.cosh() method:
Program 1:
java
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = 78.8 , num2 = 0.0 , num3 = 1.0 ;
double coshvalue = StrictMath.cosh(num1);
System.out.println( "The cosh of " +
num1+ " = " + coshvalue);
coshvalue = StrictMath.cosh(num2);
System.out.println( "The cosh of " +
num2+ " = " + coshvalue);
coshvalue = StrictMath.cosh(num3);
System.out.println( "The cosh of " +
num3+ " = " + coshvalue);
}
}
|
Output:
The cosh of 78.8 = 8.344016962852523E33
The cosh of 0.0 = 1.0
The cosh of 1.0 = 1.543080634815244
Program 2:
java
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = ( 30 * (Math.PI)) / 180 ;
double num2 = 11.0 , num3 = 45.0 ;
double coshvalue = StrictMath.cosh(num1);
System.out.println( "The cosh of " +
num1+ " = " + coshvalue);
coshvalue = StrictMath.cosh(num2);
System.out.println( "The cosh of " +
num2+ " = " + coshvalue);
coshvalue = StrictMath.cosh(num3);
System.out.println( "The cosh of " +
num3+ " = " + coshvalue);
}
}
|
Output:
The cosh of 0.5235987755982988 = 1.1402383210764286
The cosh of 11.0 = 29937.070865949758
The cosh of 45.0 = 1.7467135528742547E19
Share your thoughts in the comments
Please Login to comment...