# Compute the natural logarithm of one plus each element in floating-point accuracy Using NumPy

Last Updated : 02 Sep, 2020

Let’s see the program for computing the natural logarithm of one plus each element of a given array in floating-point accuracy using NumPy library.

For doing this task we are using numpy.log1p() function of NumPy. This function returns the array of natural logarithm of one plus each element of the input array.

Syntax: numpy.log1p(arr, out = None, *, where = True, casting = â€˜same_kindâ€™, order = â€˜Kâ€™, dtype = None, ufunc â€˜log1pâ€™)

Now, let’s see an example:

Example 1:

## Python3

 `# Import numpy library ` `import` `numpy as np ` ` `  `# Create a numpy array ` `arr ``=` `np.array([``1e``-``90``, ``1e``-``100``]) ` ` `  `# Applying the function ` `rslt ``=` `np.log1p(arr) ` ` `  `print``(rslt)`

Output:

`[1.e-090 1.e-100]`

Example 2:

## Python3

 `# Import numpy library ` `import` `numpy as np ` ` `  `# Create a numpy array ` `arr ``=` `np.array([``1``, ``2``, ``3``, ``4``]) ` ` `  `# Applying the function ` `rslt ``=` `np.log1p(arr) ` ` `  `print``(rslt)`

Output:

`[0.69314718 1.09861229 1.38629436 1.60943791]`

Example 3:

## Python3

 `# Import numpy library ` `import` `numpy as np ` ` `  `# Create a numpy array ` `arr ``=` `np.array([``1``, ``1e``-``1``, ``3``, ``1e``-``0``]) ` ` `  `# Applying the function ` `rslt ``=` `np.log1p(arr) ` ` `  `print``(rslt)`

Output:

`[0.69314718 0.09531018 1.38629436 0.69314718]`

Previous
Next