Skip to content

Natural log in Python

  • by

Use numpy log() to find the given number Natural log in Python. Python natural logarithm is the logarithm of any number to the base e.\

This is often written either as loge(x) or ln(x). Sometimes, the e is implicit, and the function is written as log(x).

Natural log in Python example

Simple example code numpy to Calculate the Natural Logarithm (ln).

import math

import numpy as np

print(np.log(math.e))
print(np.log(1))
print(np.log(10))

Output:

Natural log in Python

Math to Calculate the Natural Logarithm (ln)

import math

print(math.log(math.e))
print(math.log(1))
print(math.log(10))

Output:

1.0
0.0
2.302585092994046

Do comment if you have any doubts or suggestions on this Python log topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *