# lgamma() Function & Examples

Use the lgamma() probability function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## lgamma

#### lgamma(n)

Try it yourself:

```calculio
lgamma(4)
lgamma(1/2)
lgamma(i)
lgamma(complex(1.1, 2))
```

[gamma](https://calcul.io/function/gamma/index.md)

---

## lgamma(): Logarithm of the Gamma Function

**lgamma()** calculates the natural logarithm of the gamma function. It is useful when gamma values are enormous, because working in logarithmic space avoids overflow in likelihoods, combinatorics, and probability distributions.

## Numerical meaning

For positive integers n, gamma(n) equals (n−1)!, connecting lgamma to [factorial()](https://calcul.io/function/factorial/index.md). Use [gamma()](https://calcul.io/function/gamma/index.md) when the unlogged value is required, and [exp()](https://calcul.io/function/exp/index.md) to reconstruct a representable result.

Gamma has poles at zero and negative integers. Check the domain before evaluating, especially in parameter estimation, and prefer log-space subtraction over dividing giant gamma values directly.

[All functions](https://calcul.io/functions/index.md)
