lz_gamma
The gamma function, Γ(x).
long lz_gamma( CLZNumber* leftOperand, CLZNumber* targetNumber = nullptr );
Correctly rounded. A whole number is answered exactly, as a factorial: Γ(5) is 4!, which is 24. Anything else above nought comes from Stirling's series after a shift, and anything below nought by the reflection formula.
At nought and the negative whole numbers Γ has poles: kUndefinedResult, flagged not-a-number.
Examples
| Call | Answer | Returns |
|---|---|---|
lz_gamma( 5 ) | 24 | kNoError |
lz_gamma( 0.5 ) | 1.772453850905516027298167483341145183 | kNoError |
lz_gamma( −0.5 ) | −3.544907701811032054596334966682290366 | kNoError |
lz_gamma( 0 ) | not a number | kUndefinedResult |
lz_gamma( −2 ) | not a number | kUndefinedResult |
Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.
Returns
kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.
See also
lz_log_gammaThe natural logarithm of the gamma function, ln Γ(x), for x above nought.lz_factorialThe product of the whole numbers from one to the operand, n!.