Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python math.log1p() function is used to return 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 below example, 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