Easy Tutorial
❮ Python Os Stat Python Os Fdatasync ❯

Python math.log1p() Method

Python math Module

The math.log1p(x) method in Python returns the natural logarithm (base e) of 1+x.

Syntax

The syntax for the math.log1p() method is as follows:

math.log1p(x)

Parameter:

Return Value

Returns a float, representing the natural logarithm (base e) of 1+x.

Example

The following example returns the natural logarithm (base e) of 1+x:

Example

# Import math package
import math

# Print the natural logarithm (base e) of 1+x
print(math.log1p(2.7183))
print(math.log1p(2))
print(math.log1p(1))

Output:

1.313266574586334
1.0986122886681098
0.6931471805599453

Python math Module

❮ Python Os Stat Python Os Fdatasync ❯