Go to the source code of this file.
◆ lgamma()
template<typename T >
constexpr return_t< T > lgamma |
( |
const T |
x | ) |
|
|
constexprnoexcept |
Compile-time log-gamma function.
- Parameters
-
- Returns
- computes the log-gamma function
\[ \ln \Gamma(x) = \ln \int_0^\infty y^{x-1} \exp(-y) dy \]
using a polynomial form:
\[ \Gamma(x+1) \approx (x+g+0.5)^{x+0.5} \exp(-x-g-0.5) \sqrt{2 \pi} \left[ c_0 + \frac{c_1}{x+1} + \frac{c_2}{x+2} + \cdots + \frac{c_n}{x+n} \right] \]
where the value \( g \) and the coefficients \( (c_0, c_1, \ldots, c_n) \) are taken from Paul Godfrey, whose note can be found here: http://my.fit.edu/~gabdo/gamma.txt