Java Math exp()

That is, Math.exp(4.0) = e4.0.

The syntax of the exp() method is:

Math.exp(double a)

Here, exp() is a static method. Hence, we are accessing the method using the class name, Math.

exp() Parameters

The exp() method takes a single parameter.

  • a - number to raise e to

exp() Return Values

  • returns ea for the argument a

Note: Here, e is the Euler's number whose value is 2.71828

Example: Java Math.exp()

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

    // Math.exp() method
    double a = 4.0d;
    System.out.println(Math.exp(a));  // 54.598150033144236

    // without using Math.exp()
    // value of Euler Number
    double euler = 2.71828d;
    System.out.println(Math.pow(euler, a));  // 54.5980031309658

In the above example, we have used the Math.pow() method to compute the value of e4.0. Here, we can see that

Math.exp(4.0) = e4.0 

Also Read:

Did you find this article helpful?