# Return the natural logarithm of one plus the input array element-wise in Numpy

To return the natural logarithm of one plus the input array, element-wise., use the numpy.log1p() method in Python Numpy. It calculates log(1 + x).

For complex-valued input, log1p is a complex analytical function that has a branch cut [-inf, -1] and is continuous from above on it. log1p handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.

## Steps

At first, import the required library −

import numpy as np

Create an array using the array() method −

arr = np.array([1e-15, 10000, 1e-99])


Display the array −

print("Array...", arr)

Get the type of the array −

print("Our Array type...", arr.dtype)


Get the dimensions of the Array −

print("Our Array Dimension...",arr.ndim)

Get the shape of the Array −

print("Our Array Shape...",arr.shape)


To return the natural logarithm of one plus the input array, element-wise., use the numpy.log1p() method. Calculates log(1 + x) −

print("Result...",np.log1p(arr))

## Example

import numpy as np

# Create an array using the array() method
arr = np.array([1e-15, 10000, 1e-99])

# Display the array
print("Array...", arr)

# Get the type of the array
print("Our Array type...", arr.dtype)

# Get the dimensions of the Array
print("Our Array Dimension...",arr.ndim)

# Get the shape of the Array
print("Our Array Shape...",arr.shape)

# To return the natural logarithm of one plus the input array, element-wise., use the numpy.log1p() method in Python Numpy
# Calculates log(1 + x).
print("Result...",np.log1p(arr))

## Output

Array...
[1.e-15 1.e+04 1.e-99]

Our Array type...
float64

Our Array Dimension...
1

Our Array Shape...
(3,)

Result...
[1.00000000e-15 9.21044037e+00 1.00000000e-99]