Qu

lgamma

Builtin index · Core maths

gamma(x)

Input: x · Output: no output

What it is

The gamma function (gamma(n) = (n-1)! for a positive integer n) and its natural log (lgamma(x) = ln|gamma(x)|). x is a real scalar, Vec, or Mat/Signal. Both have a pole at every non-positive integer (0, -1, -2, ...) — evaluating there is an error, not a silent inf/NaN.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
gamma(x)
x scalar, Vec, Mat, or Signalnot documented yet
not documented yetBoth have a pole at every non-positive integer (0, -1, -2, ...) — evaluating there is an error, not a silent inf/NaN.

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.

How it works

lgamma(x) = ln|gamma(x)| -- same poles as gamma itself (ln of a pole is still a pole, not a large-but-finite number). libm::lgamma_r returns (ln|gamma(x)|, sign); only the magnitude is lgamma's contract here, matching every other language's lgamma.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.

See also

gamma — documented in the same entry.