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)
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…