Python math library | exp() method Last Updated : 07 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report Python has math library and has many functions regarding it. One such function is exp(). This method is used to calculate the power of e i.e. e^y or we can say exponential of y. The value of e is approximately equal to 2.71828….. Syntax : math.exp(y) Parameters : y [Required] - It is any valid python number either positive or negative. Note that if y has value other than number then its return error. Returns: Returns floating point number by calculating e^y. Time Complexity: O(1)Auxiliary Space: O(1) Code # 1: python3 # Python3 code to demonstrate # the working of exp() import math # initializing the value test_int = 4 test_neg_int = -3 test_float = 0.00 # checking exp() values # with different numbers print (math.exp(test_int)) print (math.exp(test_neg_int)) print (math.exp(test_float)) Output:54.598150033144236 0.049787068367863944 1.0 Code #2: python3 # Python3 code to demonstrate # the working of exp() import math # checking exp() values # with inbuilt numbers print (math.exp(math.pi)) print (math.exp(math.e)) Output:23.140692632779267 15.154262241479262 Code #3: TypeError python3 # Python3 code to demonstrate # the working of exp() import math # checking for string print (math.exp("25")) Output: Traceback (most recent call last): File "/home/c7ae4f1bef0ed8c7756b3f55e7d2ce81.py", line 6, in print (math.exp("25")) TypeError: a float is required Comment More infoAdvertise with us Next Article Python | Decimal logb() method A AKASH GUPTA 6 Follow Improve Article Tags : Python Python math-library Python math-library-functions Practice Tags : python Similar Reads Python math library | expm1() method Python has math library and has many functions regarding to it. One such function is expm1(). This function mathematically computes the value of exp(x) - 1. This method can be used if we need to compute this very value. Syntax : math.expm1() Parameters : x : Number whose exp(x)-1 has to be computed. 2 min read Python | cmath.exp() method With the help of cmath.exp() method, we can find the exponent of any number by passing it to cmath.exp() method. Syntax : cmath.exp(value) Return : Return the exponential value. Example #1 : In this example we can see that by using cmath.exp() method, we are able to get the values of exponent by pas 1 min read Python | Decimal ln() method Decimal#ln() : ln() is a Decimal class method which returns the natural (base e) logarithm of the Decimal value. Syntax: Decimal.ln() Parameter: Decimal values Return: the natural (base e) logarithm of the Decimal value. Code #1 : Example for ln() method Python3 # Python Program explaining # ln() me 2 min read Python | Decimal exp() method Decimal#exp() : exp() is a Decimal class method which returns the value of the (natural) exponential function e**x at the given number Syntax: Decimal.exp() Parameter: Decimal values Return: the value of the (natural) exponential function e**x at the given number Code #1 : Example for exp() method P 2 min read Python | Decimal logb() method Decimal#logb() : logb() is a Decimal class method which returns the adjusted exponent of the Decimal value. Syntax: Decimal.logb() Parameter: Decimal values Return: the adjusted exponent of the Decimal value. Code #1 : Example for logb() method Python3 # Python Program explaining # logb() method # l 2 min read Python | sympy.expand() method With the help of sympy.expand() method, we can expand the mathematical expressions in the form of variables by using sympy.expand() method. Syntax : sympy.expand(expression) Return : Return mathematical expression. Example #1 : In this example we can see that by using sympy.expand() method, we can g 1 min read Like