JavaScript Math.exp(x) Method

Shubham Vora Jan 30, 2023
  1. Syntax of JavaScript Math.exp(x):
  2. Example Code: Use the Math.exp(x) Method to Get the Exponential Value of a Number
  3. Example Code: Use the Math.exp(x) Method to Experiment and Find Value of the Different Numbers
JavaScript Math.exp(x) Method

The Math.exp(x) method is used to get the value of the number e raised to a power (x). Here x is the given number, and e is 2.7183, considered the base of the natural logarithms.

Syntax of JavaScript Math.exp(x):

Math.exp(x);

Parameters

x The number that will be considered the power of e. Here, e is the base of natural logarithms.

Return

This method returns the value of e raised to a power (x).

Example Code: Use the Math.exp(x) Method to Get the Exponential Value of a Number

We can use the Math.exp(x) method to get a value of e raised to power x. In this example, we used the Math.exp(x) method to get the value of a number.

const x = 4;
let exp = Math.exp(x);
console.log(exp);

Output:

54.598150033144236

Example Code: Use the Math.exp(x) Method to Experiment and Find Value of the Different Numbers

The Math.exp(x) method allows the multiplication method to get a similar result. We can use the Math.exp(x) method to get the same result as Math.exp(y)*Math.exp(z), if x is equal to y+z.

In this example, we have used the multiplication method to get the output of Math.exp(x).

let exp = Math.exp(2) * Math.exp(3);
let e = Math.exp(5);
console.log(exp);
console.log(e);

Output:

148.4131591025766
148.4131591025766

In the above output, users can see that Math.exp(2)*Math.exp(3) gives the same result as Math.exp(5) because of 2+3=5.

The Math.exp(x) method is supported in all browsers. In the Math.exp(x) method, Math is considered a placeholder object that includes all the mathematical functions.

Author: Shubham Vora
Shubham Vora avatar Shubham Vora avatar

Shubham is a software developer interested in learning and writing about various technologies. He loves to help people by sharing vast knowledge about modern technologies via different platforms such as the DelftStack.com website.

LinkedIn GitHub

Related Article - JavaScript Math