gamma
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.
| Code | Input | Output | Description |
gamma(x) | x scalar, Vec, Mat, or Signalnot documented yet | not documented yet | Both 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
gamma/lgamma/erf/erfc: checked Cargo.lock first for an existing implementation in the dependency tree (none -- see Cargo.toml's own note on adding libm) before writing anything. libm matches C's libm bit-for-bit-ish reference behavior, so this does not hand-roll Stirling's approximation (wrong in the last few digits for large x, and badly wrong near a pole) or a rational erf series (erfc's whole point -- see below -- is exactly the kind of tail behavior a hand rolled series gets wrong first). gamma(x) has a pole at every non-positive integer (0, -1, -2, ...); libm::tgamma does not error there (IEEE 754 hands back inf/NaN silently), so this checks first, same convention as coth/csch/atanh above.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.
See also
lgamma — documented in the same entry.