log1p()
function is used to find the the natural logarithm of 1+x (base e) in Python for the given input(x – parameter).
Syntax of log1p()
Function
The syntax of
log1p()
function in Python is:
math.log1p(x)
Parameters of log1p()
Function in Python
x
– Where x
is any valid python number (positive or negative). This parameter is required.Note: If the
x
parameter is not a number, log1p()
function will return an Error.
Compatibility
log1p()
function is available and compatible with both Python 2.x
and 3.x
. This function is a part of python standard math library.
Return Value of log1p()
Function in Python
log1p()
function returns the natural logarithm of 1+x (base e) for the given input.
Python log1p()
Function Example
# import math library import math print(math.log1p(-0.2)) print(math.log1p(0)) print(math.log1p(0.2)) print(math.log1p(77)) print(math.log1p(-3677))
Output: