# How to Compute the Natural Logarithm (ln) of a Number in Python

A natural logarithm is the inverse of the exponential function. To get the natural logarithm (ln) of a number in Python, use the `.log()`

function from the `math`

package.

Import the math package then call `math.log()`

function passing the number to compute to get its natural logarithm.

```
import math
nat_ln = math.log(1)
print(nat_ln)
```

```
0.0
```

## Compute Natural Logarithm with NumPy

NumPy has a `log()`

function – if you are already using NumPy you can save some memory by not importing `math`

and using `numpy.log()`

instead.

```
import numpy
nat_ln = numpy.log(1)
print(nat_ln)
```

```
0.0
```