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 $e^{x}- 1$. It takes the value $x$ as argument and returns the result of $e^{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 $e$ in the expression $e^x - 1$.

### Return value

The method returns a primitive double type value which is the result of the $e^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

Learn in-demand tech skills in half the time