How to calculate the natural logarithm of the Euler Mascheroni constant in Python?

By IncludeHelp Last updated : November 25, 2023

Euler-Mascheroni Constant

The Euler-Mascheroni constant (also known as the Euler's constant or Mascheroni's constant) is a mathematical constant that is represented by the Greek letter γ (gamma). It is named after the mathematicians Leonhard Euler and Lorenzo Mascheroni, who independently discovered its properties.

Natural logarithm of the Euler Mascheroni constant

To calculate the natural logarithm of the Euler's constant, get the value of Euler's constant by using the np.euler_gamma() method and then use the np.log() method to get its natural logarithm value.

Example

Below is a Python program to find the natural logarithm of the Euler Mascheroni constant.

# Importing numpy library
import numpy as np

# Defining a variable and storing Euler's constant
eu = np.euler_gamma

# Printing the value
print("Euler's constant is :", eu)

# Finding log of Euler's constant
result = np.log(eu)

# Printing the result
print("Log of Euler's constant is :", result)

Output

The output of the above example is:

Euler's constant is : 0.5772156649015329
Log of Euler's constant is : -0.5495393129816448

Python NumPy Programs »

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.