Python math.log1p() Method
Python math.log1p(x)The method returns the natural logarithm of 1+x (base e).
Syntax
The syntax of the math.log1p() method is as follows:
math.log1p(x)
Parameter Description:
- x-- Required, a number. If x is not a number, TypeError is returned. If the value is 0 or negative, ValueError is returned.
Return Value
Returns a float, representing the natural logarithm of 1+x to base e.
Example
The following example returns the natural logarithm of 1+x to base e:
Example
# Import the math package
import math
# Output the natural logarithm of 1+x to base e
print(math.log1p(2.7183))
print(math.log1p(2))
print(math.log1p(1))
import math
# Output the natural logarithm of 1+x to base e
print(math.log1p(2.7183))
print(math.log1p(2))
print(math.log1p(1))
Output result:
1.313266574586334 1.0986122886681098 0.6931471805599453Other Extensions
Python math Module