a shot of dev knowledge

RELATED TAGS

What is Math.expm1() in Java?

The expm1() method from the java.lang.Math class can be used to calculate the exponential function ex1e^{x}- 1. It takes the value xx as argument and returns the result of ex1e^{x}- 1.

Syntax


static double expm1(double x)

Parameters

The expm1() method takes the following input parameter.

  • x: A double type argument value that represents the power of ee in the expression ex1e^x - 1.

Return value

The method returns a primitive double type value which is the result of the ex1e^x - 1 expression.

  • The result is NaN if the argument value is NaN.

  • The result is -1.0 if the argument is negative infinity.

  • The result is positive infinity if the argument value is positive infinity.

Code

  • Case 1: Positive number as an argument.

  • Case 2: Negative number as an argument.

  • Case 3: Zero as an argument value.

  • Case 4: Positive infinity as an argument.

  • Case 5: Negative infinity as an argument.

Execute the code below to see the output.

// Load library
import java.lang.Math;
// Main class
class EdPresso {
    public static void main( String args[] ) {
        System.out.println(Math.expm1(6));
    }
}

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring