cosh() in Java

cosh(): This method is available in the Math class of Java.

Syntax:

double java.lang.Math.cosh(double x)

This method takes one argument of type double . This method returns the hyperbolic cosine of a double value. The hyperbolic cosine of x is defined to be(ex + e-x)/2.

Note: where e is Euler's number.

Special cases:

1. If the argument is NaN, then the result is NaN.

2. If the argument is infinite, then the result is positive infinity.

3. If the argument is zero, then the result is 1.0.

The computed result must be within 2.5 ulps of the exact result. \

Parameters: One parameter is required for this method.

x: The number whose hyperbolic cosine is to be returned.

Returns: The hyperbolic cosine of x.

For Example:

Math.cosh(2.3344) = > It returns 5.210066349294121

Approach

Java

public class Cosh {
    public static void main(String[] args) {

        double x = 2.3344;
        System.out.println(Math.cosh(x));

    }
}

Output:

5.210066349294121

No comments:

Post a Comment