How to use EXP() to get Raise to the power of values in MySQL8?

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.


MySQL EXP() : Syntax

EXP ( X );

MySQL EXP() : Parameter

Name, Required /Optional, Description
X , Required, Double , It represents a valid number.


MySQL EXP() : Output

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.


MySQL EXP()  Available from : MySQL 4.0


EXP() Example 1 : Basic Examples

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)

EXP() Example 2 : Negative values

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)

EXP() Example 3 : Passing Zero (0) as an input

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)

EXP() Example 4 : With Expressions

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)

EXP() Example 5 : NULL arguments

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)

EXP() Example 6 : RETURN the value of e

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)

Related articles : PI(), MySQL Maths.

jyoti rani

Recent Posts

Modern Toys, Magical Moments: Why the Best Toy Shop in Noida Is More Than Just a Store

When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…

3 weeks ago

Rediscovering Joy: A New Era of Creativity & Comfort in Toy Stores

In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…

3 weeks ago

Unboxing Imagination: Discovering the Joy of Play at a Toy Store in Noida

In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…

4 weeks ago

Imagination Unboxed: Discover Joy at the Toy Shop in Delhi

In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…

4 weeks ago

Play with Purpose: Discovering the Ultimate Toy Store in Noida

When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…

4 weeks ago

From Tears to Toys: Exploring Modern Childhood through Delhi’s Favorite Toy Shop

In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…

4 weeks ago