Python math library | exp() method Last Updated : 07 Feb, 2023 Comments Improve Suggest changes 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 math library | exp() 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 Dunder or magic methods in Python Python Magic methods are the methods starting and ending with double underscores '__'. They are defined by built-in classes in Python and commonly used for operator overloading. They are also called Dunder methods, Dunder here means "Double Under (Underscores)". Python Magic MethodsBuilt in classes 7 min read Python | Decimal log10() method Decimal#log10() : log10() is a Decimal class method which returns the base ten logarithm of the Decimal value. Syntax: Decimal.log10() Parameter: Decimal values Return: the base ten logarithm of the Decimal value. Code #1 : Example for log10() method Python3 # Python Program explaining # log10() met 2 min read Python | Decimal adjusted() method Decimal#adjusted() : adjusted() is a Decimal class method which returns the adjusted exponent after shifting out the coefficientâs rightmost digits until only the lead digit remains Syntax: Decimal.adjusted() Parameter: Decimal values Return: the adjusted exponent after shifting out the coefficientâ 2 min read Python | sympy.expand_log() method With the help of sympy.expand_log(), we can simplify the log terms in the mathematical expression by using the following properties that are listed below. Properties : 1) log(x*y)=log(x)+log(y) 2) log(x**n)=nlog(x) Syntax : sympy.expand_log() Return : Return the simplified mathematical expression. E 1 min read Like