Easy Tutorial
❮ Python File Seek Python String Swapcase ❯

Python math.lgamma() Method

Python math Module

The math.lgamma(x) method in Python returns the natural logarithm of the gamma value of a number.

We can also find the gamma value using the math.gamma() method and then calculate the natural logarithm of that value using the math.log() method.

The gamma value is equal to factorial(x-1).

Python Version: 3.2

Syntax

The syntax for the math.lgamma() method is as follows:

math.lgamma(x)

Parameter Description:

Return Value

A floating-point value representing the natural logarithm of the gamma value of a number.

Example

The following example calculates the natural logarithm of the gamma value for different numbers:

Example

# Import math package
import math

# Calculate the natural logarithm of the gamma value for different numbers
print(math.lgamma(7))
print(math.lgamma(-4.2))

Output result:

6.579251212010102
-1.8075166614192908

Python math Module

❮ Python File Seek Python String Swapcase ❯