Python math - log1p() Function
The Python math.log1p() function returns the natural logarithm of (1 + number), i.e., log(1+number).
Syntax
math.log1p(x)
Parameters
x |
Required. Specify the number. |
Return Value
Returns the natural logarithm of (1 + number), i.e., log(1+number).
Example:
In the example below, log1p() function is used to calculate the log(1+number).
import math print(math.log1p(0)) print(math.log1p(1)) print(math.log1p(2))
The output of the above code will be:
0.0 0.6931471805599453 1.0986122886681096
❮ Python Math Module