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

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]`

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.