The Wayback Machine - https://web.archive.org/web/20240927091229/https://www.geeksforgeeks.org/javascript-math-exp-method/
Open In App

JavaScript Math exp() Method

Last Updated : 15 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The JavaScript Math exp( ) Method is used to return ex, where x is the argument, and e is Euler’s number, which is the base of the natural logarithms. The exp() is a static method of Math, therefore, it is always used as Math.exp(), rather than as a method of a Math object created.

Syntax:  

Math.exp(value)

Parameters:

This function accepts a single parameter as mentioned above and described below:  

  • Value is a number whose ex you want to find.

Return Value:

  • The Math.exp() method returns ex where e is Euler’s number and x is the argument.

Example 1: Below is an example of the Math exp() Method. 

JavaScript
console.log("When zero is passed as a parameter: "
    + Math.exp(0));

Output
When zero is passed as a parameter: 1

Example 2: When “-1” is passed as a parameter.

JavaScript
console.log("Result : " + Math.exp(-1));

Output
Result : 0.36787944117144233

Example 3: When “1” is passed as a parameter. 

JavaScript
console.log("Result : " + Math.exp(1));

Output
Result : 2.718281828459045

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

Supported Browsers: 

  • Chrome 51
  • Edge 15
  • Firefox 54
  • Safari 10
  • Opera 38

JavaScript Math exp() Method – FAQs

What does the Math.exp() method do in JavaScript?

The Math.exp() method returns e (Euler’s number, approximately 2.718) raised to the power of a given number.

How does Math.exp() handle non-numeric arguments?

If the argument is not a number, Math.exp() first attempts to convert it to a number. If the conversion is not possible, the result is NaN (Not-a-Number).

Can Math.exp() handle special numeric values like NaN, Infinity, and -Infinity?

  • Math.exp(NaN) returns NaN.
  • Math.exp(Infinity) returns Infinity.
  • Math.exp(-Infinity) returns 0.

What are common use cases for the Math.exp() method?

  • Exponential Growth Calculations: Using Math.exp() to model exponential growth or decay in finance, biology, and physics.
  • Scientific Calculations: Implementing formulas and algorithms that require the exponential function.

How can Math.exp() be used with variables?

Math.exp() can be used with variables that hold numeric values. For example: Math.exp(x) where x is a variable containing a number.

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.


Previous Article
Next Article

Similar Reads

PHP Math Functions (is_nan, pow, sqrt, exp, log, log10, log1p, max, min, getrandmax, rand, mt_rand)
11. is_nan() : This function takes any value as argument and checks whether a value is number or not. It returns TRUE (1) if the specified value is 'not a number', otherwise it returns FALSE/NOTHING. Syntax : is_nan(value); Example : C/C++ Code <?php echo is_nan(234) . "\n"; echo is_nan(asin(1.1)) ; ?> Output : 1 Not
4 min read
p5.js exp() Method
The exp() function returns the value of n (any number) to the Euler's number e(2.71828...) raised to the power n (e^n). Syntax: exp(n) Parameters: This method accepts a single parameters n i.e. the number value. Return Value: It returns (e^n) of the given number. Example 1: C/C++ Code function setup() { // Create Canvas of size 270*80 createCanvas(
2 min read
PHP exp() Function
Euler's Number or commonly known as e is a very popular irrational number which approximates to 2.718281828, and is one of the most important mathematical constants. e is the base of the Natural system of logarithms. The exponential values are broadly used in many occasions such as Compound Interests, Bernoulli trials, Normal Distribution, Calculus
1 min read
Adobe Interview Experience ( 3 Years Exp )
I was called to Noida office of Adobe situated in sector 132 Noida. Round 1: Remove half nodes from a binary tree. (Half Nodes = Nodes with only one child) Find the number of Rectangles with 1s at 4 corners in a 2D array of 1s and 0s Javascript Question : Closure and setTimeOut
1 min read
Tensorflow.js tf.exp() Function
Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .exp() function is used to find the exponential value i.e, (e^x) of the stated tensor input, and it is done element wise. Syntax : tf.exp(x) Parameters: x: It
2 min read
JavaScript Math tan() Method
The Javas Math.tan() method in Javascript is used to return the tangent of a number. The Math. tan() method returns a numeric value that represents the tangent of the angle. The tan() is a static method of Math, therefore, it is always used as Math.tan(), rather than as a method of a Math object created. Syntax: Math.tan(value)Parameters: This meth
2 min read
JavaScript Math acosh() Method
The Javascript Math.acosh() function in Javascript is used to return the hyperbolic arc-cosine of a number. Math.acosh (x) = arcosh(x) = y ≧ 0 such that cosh (y)=x acosh() is a static method of Math, therefore it is always used as Math.acosh(), rather than as a method of a Math object created. Syntax: Math.acosh(value) Parameters: This function acc
2 min read
JavaScript Math atan2() Method
Javascript Math.atan2() method is used to return the arctangent of the quotient of its arguments. The Math.atan2() method returns a numeric value between -Π and Π representing the angle theta of an (x, y) point and the positive x-axis. This is the counterclockwise angle, measured in radians, between the positive X-axis, and the point (x, y). Syntax
1 min read
JavaScript Math.asinh() Method
The Javascript Math.asinh() function is used to return the hyperbolic arc-sine of a number. The asinh() is a static method of Math, therefore it is always used as Math.asinh(), rather than as a method of a math object created. Syntax: Math.asinh(value) Parameter: This function accepts a single parameter value which is the number whose hyperbolic ar
2 min read
JavaScript Math tanh() Method
Javascript Math.tanh() method is used to calculate the value of the hyperbolic tangent of a number. Syntax: Math.tanh(x)Parameter: This method accepts a single parameter as mentioned above and described below: x: which is a number for which the value of hyperbolic tangent is going to be calculated.Return value: It returns the calculated value of th
3 min read
JavaScript Math asin() Method
The Math.asin( ) method is used to return the arcsine of a number in radians. The Math.asin() method returns a numeric value between -pi/2 and pi/2 radians. The asin() is a static method of Math, therefore, it is always used as Math.asin(), rather than as a method of a Math object created. Math.asin(x)=arcsin(x)=unique y where y belongs to [-pi/2;p
2 min read
JavaScript Math imul() Method
The Javascript Math.imul() method in JavaScript is used to calculate the result of the 32-bit multiplication of the two integers passed as parameters to it. Math.imul() allows for 32-bit integer multiplication with C-like semantics. If the Math.imul() method is used with normal floating type variables in JavaScript then there will be a degradation
2 min read
JavaScript Math cbrt() Method
The Math.cbrt() method is used to find the cube root of a number. Syntax: Math.cbrt(x)Parameters: This method accepts a single parameter as mentioned above and described below: x: This parameter is simply a number whose cube root needs to be found.Returns: It returns the cube root of the given number. Example: Below is an example of the Math.cbrt()
3 min read
JavaScript Math log1p() Method
Javascript Math.log1p() is an inbuilt function in JavaScript that gives the value of the natural logarithm of 1 + p number. The natural logarithm is of base e, where e is an irrational and transcendental number approximately equal to 2.718. Syntax: Math.log1p(1 + p)Below example illustrate the JavaScript Math.log1p() Method in JavaScript: Example 1
4 min read
JavaScript Math cosh() Method
JavaScript Math.cosh() method is used to calculate the value of the hyperbolic cosine of a number. Syntax: Math.cosh(x)   Parameter: This method accepts a single parameter as mentioned above and described below: x: This parameter holds a number for which the value of hyperbolic cosine is going to be calculated.Returns: It returns the calculated val
3 min read
JavaScript Math sinh() Method
The JavaScript Math.sinh() is an inbuilt method in JavaScript that is used to calculate the value of the hyperbolic sine of a number. Syntax: Math.sinh(p) Examples: Input : Math.sinh(0) Output : 0 Explanation: Here formula for calculating the hyperbolic sine of any number is: The number e is a mathematical constant having an approximate value equal
4 min read
JavaScript Math atanh() Method
The Javascript Math.atanh() method is used to return the hyperbolic arctangent of a number. The atanh() is a static method of Math, therefore it is always used as Math.atanh(), rather than as a method of a Math object created. Math.atanh (x) = arctanh(x) = y such that tanh (y) = x Syntax: Math.atanh(value) Parameters: This method accepts a single p
3 min read
JavaScript Math fround( ) Method
The Javascript Math.fround() method is used to return the nearest 32-bit single-precision float representation of a number. The Math.fround() method in JavaScript is also used to cast the 64-bit float to a 32-bit float. Syntax: Math.fround(value)Parameters: This method accepts a single parameter value. This parameter represents the number for which
2 min read
JavaScript Math expm1() Method
Math.expm1() is an inbuilt method in JavaScript that is used to get the value of ep-1, where p is any given number. The number e is a mathematical constant having an approximate value equal to 2.718. It was discovered by the Swiss mathematician Jacob Bernoulli. This number is also called Euler's number. Syntax: Math.expm1(p) Parameter: p: This para
3 min read
JavaScript Math acos() Method
The Javascript Math.acos( ) method is used to return the arccosine of a number in radians. The Math.acos() method returns a numeric value between 0 and pi radians. The Math acos() is a static method of Math, therefore, it is always used as Math.acos(), rather than as a method of a Math object created. Math.acos(x)=arccos(x)=unique y, where y belong
3 min read
JavaScript Math log2() Method
The Javascript Math.log2() is an inbuilt method in JavaScript that gives the value of base 2 logarithms of any number. Syntax: Math.log2(p)Parameters: This method accepts a single parameter p which is any number whose base 2 logarithms is to be calculated. Returns: It returns the value of base 2 logarithms of any number. Let's see some JavaScript c
3 min read
JavaScript Math asinh() Method
JavaScript Math.asinh() method is used to get the hyperbolic arc-sine of a number. The hyperbolic arc-sine is known by many names such as hyperbolic inverse sine and asinh. It is the inverse of the hyperbolic sine function i.e., The inverse hyperbolic sine of any value says x is the value y for which the hyperbolic cosine of y is x. if y = asinh(x)
3 min read
JavaScript Math acosh() Method
Javascript Math.acosh() method is used to get the hyperbolic arc-cosine of a number. The hyperbolic arc-cosine is known by many names such as hyperbolic inverse cosine and acosh. It is the inverse of the hyperbolic cosine method i.e., The inverse hyperbolic cosine of any value say x is the value y for which the hyperbolic cosine of y is x. if y = a
2 min read
JavaScript Math clz32() Method
JavaScript Math.clz32() is an inbuilt method in JavaScript that stands for "Count Leading Zeroes 32". This method is used for getting the number of leading zero bits present in the 32-bit representation of a number. Syntax: Math.clz32(p)Parameters: this method accepts a single parameter p, which is a number for which the number of leading zero bits
3 min read
JavaScript Math log10() Method
The Javascript Math.log10() is an inbuilt method in JavaScript that gives the value of base 10 logarithms of any number. Syntax:Math.log10(p)Parameters: This method accepts a single parameter p which is any number whose base 10 logarithms is to be calculated.Return Value: It returns the value of base 10 logarithms of any numberExample 1: This examp
3 min read
JavaScript Math atan() Method
Javascript Math.atan( ) method is used to return the arctangent of a number in radians. The Math.atan() method returns a numeric value between -pi/2 and pi/2 radians. The atan() is a static method of Math, therefore, it is always used as Math.atan(), rather than as a method of a Math object created. Math.atan(x)=arctan(x)=unique y where y belongs t
3 min read
JavaScript Math cos() Method
The Javascript Math.cos() method is used to return the cosine of a number. The Math.cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians. The cos() is a static method of Math, therefore, it is always used as Math.cos(), rather than as a method of a Math object created. Syntax: Math.cos(val
2 min read
JavaScript Math ceil() Method
The JavaScript Math.ceil method is used to return the smallest integer greater than or equal to a given number. The ceil() is always used as Math.ceil() since it is a static method of Math. Syntax:Math.ceil(value)Parameters: This method accepts single parameters as mentioned above and described below: Value: It is the value that is to be tested for
2 min read
JavaScript Math hypot( ) Method
The Math.hypot() method in JavaScript is used to calculate the square root of the sum of squares of numbers passed to it as arguments. It is basically used to find the hypotenuse of a right-angled triangle or the magnitude of a complex number. Math.hypot() method uses the formula Math.sqrt(v1*v1 + v2*v2) where v1 and v2 are either the sides of the
3 min read
JavaScript Math sqrt() Method
The JavaScript Math sqrt( ) Method in JavaScript is used to square the root of the number passed as a parameter to the function. Syntax:Math.sqrt(value)Parameters:This method accepts a single parameter as mentioned above and described below: Value: which holds the number whose square root is to be calculated.Return Value: The square root of the num
2 min read