With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. EXP(X) returns the value of e (the base of natural logarithms) raised to the power of X.
Now let’s start with it.
EXP(X) is a mathematical function. It returns the value of e (the base of natural logarithms) raised to the power of X. Where X is the value passed as an argument.
The constant e value is approximately 2.718281, is the base of natural logarithms.
You provide the specified value as an argument when calling the function.
The number e is a mathematical constant that is the base of the natural logarithm: the unique number whose natural logarithm is equal to one. It is approximately equal to 2.71828.
The opposite of this function is LOG() (using a single argument only) or LN().
It will return NULL, if X is passed as NULL.
It returns error, if any String argument is passed as an input.
Name, Required /Optional, Description
X , Required, Double , It represents a valid number.
Return, Description
NULL, if the argument is NULL.
Double, It returns the value of e (the base of natural logarithms) raised to the power of input number.
Now, Let’s see some of the basic examples of it and see what it returns.
mysql> SELECT EXP(5); +-------------------+ | EXP(5) | +-------------------+ | 148.4131591025766 | +-------------------+ 1 row in set (0.00 sec)
Now, Let’s see an example with a negative value and see what it returns.
mysql> SELECT EXP(-5); +----------------------+ | EXP(-5) | +----------------------+ | 0.006737946999085467 | +----------------------+ 1 row in set (0.07 sec)
See the output, we have got 1 as result, when Zero (0) is passed as input.
mysql> SELECT EXP(0); +--------+ | EXP(0) | +--------+ | 1 | +--------+ 1 row in set (0.00 sec)
We are using the EXP() function with expressions. See the below example.
mmysql> SELECT EXP(1+1); +------------------+ | EXP(1+1) | +------------------+ | 7.38905609893065 | +------------------+ 1 row in set (0.04 sec) mysql> SELECT EXP(3*2); +-------------------+ | EXP(3*2) | +-------------------+ | 403.4287934927351 | +-------------------+ 1 row in set (0.00 sec)
If the argument is NULL, it will return NULL. See the below example :
mysql> SELECT EXP(NULL); +-----------+ | EXP(NULL) | +-----------+ | NULL | +-----------+ 1 row in set (0.52 sec)
Passing 1 as a user input return the value of e (that is, e to the power of 1). See the below example :
mysql> SELECT EXP(1); +-------------------+ | EXP(1) | +-------------------+ | 2.718281828459045 | +-------------------+ 1 row in set (0.00 sec)
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…