StrictMath.tanh() in Java

StrictMath.tanh(): This method is available in java.lang.StrictMath class of Java,

Syntax:

double java.lang.StrictMath.tanh(double x)

This method takes one argument of type double as its parameter. This method returns the hyperbolic tangent of a double value.The hyperbolic tangent of x is defined to be(ex - e-x)/(ex + e-x),in other words, sinh(x)/cosh(x).

Note:

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

2. If the argument is zero, then the result is a zero with the same sign as the argument.

3. If the argument is positive infinity, then the result is +1.0.

4. If the argument is negative infinity, then the result is -1.0.

Parameters: One parameter is required for this method.

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

Returns: The hyperbolic tangent of x.

Exceptions: NA

Approach

Java

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

        double x = 1.67;
        System.out.println(StrictMath.tanh(x));
    }
}

Output:

0.9315516846152082


No comments:

Post a Comment