MySQL - EXP() Function



The MySQL EXP() function is used to calculate the Euler's number 'e' raised to the power of a given double value.

The Euler's number is simply defined as a mathematical expression that is usually used as the base of natural logarithms. It is a non-terminating and a non-recurring decimal number that holds the value of 2.718281828459045... However, the number is constricted to only two decimals in most problems to be solved, i.e., 2.71.

This function accepts a number as an argument, calculates the base of the natural logarithms, e, to the power of the given value. In other words, this function returns ex, where x is the argument, and 'e' is Euler's constant, the base of the natural logarithms. This Euler's number is mostly used in problems that deal with exponential functions (either increasing or decreasing).

Syntax

Following is the syntax of EXP() function in MySQL −

EXP(x);

Parameters

This function takes a numeric value as a parameter.

Return Value

This function returns the exponential value (ex) of the given value.

Example

The following query uses the MySQL EXP() function to calculate the value of the Euler's number 'e' raised to the power of 1 −

SELECT EXP(1) As Result;

Output

This will produce the following result −

Result
2.718281828459045

Example

Following is another example of the EXP() function −

SELECT EXP(30) As Result;

Output

The output will be displayed as below −

Result
10686474581524.463

Example

You can also pass the number as a string value to this function −

SELECT EXP('0.5') As Result;

Output

This will produce the following result −

Result
1.6487212707001282

Example

You can also pass negative values as argument to this function −

SELECT EXP(-1) As Result;

Output

The output for the query above is produced as given below −

Result
0.36787944117144233
Advertisements