A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/python_math_expm1_method.htm below:

Python math.expm1() Method

Python math.expm1() Method

The Python math.expm1() method is used to calculate the value of ex − 1, where e is the base of the natural logarithm (Euler's number) and x is the input parameter. It calculates the exponential of the input value minus 1.

Mathematically, the math.expm1() method is equivalent to ex − 1, where e is approximately equal to 2.71828.

For example, if x = 1, then math.expm1(1) returns e1 − 1, which simplifies to e − 1.

Syntax

Following is the basic syntax of the Python math.expm1() method −

math.expm1(x)
Parameters

This method accepts either an integer or a floating-point number as a parameter, representing the exponent to which e is raised.

Return Value

The method returns the value of e raised to the power of x, minus 1. The return value is a floating-point number.

Example 1

In the following example, we calculate e raised to the power of 1 minus 1, which means passing a positive integer exponent as a parameter to the base e −

import math
result = math.expm1(1)
print("The result obtained is:", result)  
Output

The output obtained is as follows −

The result obtained is: 1.718281828459045
Example 2

Here, we pass a negative integer exponent to the base e as a parameter. We calculate e raised to the power of -2 minus 1 −

import math
result = math.expm1(-2)
print("The result obtained is:", result)  
Output

Following is the output of the above code −

The result obtained is: -0.8646647167633873
Example 3

In this example, we are passing a fractional exponent as a parameter to the base e. We are calculating e raised to the power of 1.5 minus 1 −

import math
result = math.expm1(1.5)
print("The result obtained is:", result) 
Output

We get the output as shown below −

The result obtained is: 3.481689070338065
Example 4

Now, we use a variable "x" to store the exponent value. We then calculate e raised to the power of "x" minus 1, which is e2 - 1 −

import math
x = 2
result = math.expm1(x)
print("The result obtained is:", result)  
Output

The result produced is as shown below −

The result obtained is: 6.38905609893065

python_maths.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4