# Java Math exp() Function ## Java Math Class

Java Math class provides several methods to perform several operations on math calculations like max(), min(), sin(), cos(), round(), ceil(), floor(), abs(), exp Function etc.
The java.lang.Math class contains various methods for performing basic numeric operations

Here, in the page we will discuss about the exp Function of Math class in java.

## Java exp Function :

Java Collection contains Math class and The class Math contains methods for performing basic and advance numeric operations such as the exponential, logarithm, square root, and trigonometric functions.
The exp Function of math class in Java returns the Euler’s number e raised to the power of the input value. It is a static function so we can access it by using the Math class.

#### Syntax:

`Math.exp(number);`

#### Return Type :

• If the input is + or – value, this method will return the output.
• If the input is Zero, this method will return 1.0.
• If the input is + Infinity, this method will return + Infinity.
• If the input is – Infinity, this method will return + Zero.
• If the input is NaN, this method will return NaN.

#### Example :

Run
```import java.util.*;

public class Main{
public static void main(String[] args){
// Initializing double argumnet
double num = 2.0d;

// taking exp value
double ans = Math.exp(num);

System.out.println("Exponential value for the given Input is : " + ans);

// using exact value of e
double ans2 = Math.pow(2.71828,2.0d);

System.out.println("Exponential value using e value is : " + ans2);
}
}```
```Output:

Exponential value for the given Input is : 7.38905609893065
Exponential value using e value is : 7.3890461584
```

In the above Example, We had taken a variables of double type with a value stored in it. we are printing the exponential value using the exp function and also using the value of e.

#### Example:

Run
```import java.util.*;

public class Main{
public static void main(String[] args){
// Initializing double negative argumnet
double num = -2.0d;

System.out.println("Exponential value for the given Input is : " + Math.exp(num));

// Initializing argument as negative infinity
double num2 = Double.NEGATIVE_INFINITY;

System.out.println("Exponential value for negative infinity is : " + Math.exp(num2));

// Initializing 0 argument
double num3 = 0;

System.out.println("Exponential value for 0 is : " + Math.exp(num3));
}
}```
```Output:

Exponential value for the given Input is : 0.1353352832366127
Exponential value for negative infinity is : 0.0
Exponential value for 0 is : 1.0
```

In the above Example, We had taken example for exponent value of the negative number, 0, and negative infinity.

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others