The gamma function of a complex ball
#include <flint/acb_hypgeom.h>Sets res to the gamma function . The result is indeterminate if contains a pole.
Real input is passed to arb_hypgeom_gamma. Otherwise the function uses the tabulated Taylor series of acb_hypgeom_gamma_taylor near the real axis at low and moderate precision and the Stirling series of acb_hypgeom_gamma_stirling elsewhere. See The gamma function of a complex ball. acb_gamma calls this function.
Sets res to the reciprocal gamma function , which is entire.
Uses the same methods as acb_hypgeom_gamma. If the Stirling series gives no finite enclosure (a wide ball), it returns the bound for instead. acb_rgamma calls this function.
Sets res to the principal branch of the log-gamma function , which is analytic except on the branch cut and differs from by a multiple of .
Positive real input is passed to arb_hypgeom_lgamma. Near the real axis at moderate precision, the function computes with the Taylor series for with real part in (where the branch is determined by tabulated bounds for the imaginary part), and corrects the shift and the reflection with acb_hypgeom_log_rising_ui and acb_log_sin_pi. Elsewhere it uses the Stirling series, which gives directly, with argument reduction by the log-rising factorial and, for negative real parts, the reflection formula with the branch of acb_log_sin_pi. See The logarithm of the gamma function. acb_lgamma calls this function.
acb_hypgeom_gamma, acb_hypgeom_rgamma and acb_hypgeom_lgamma compute , and the principal branch of for a complex ball . They are the implementations behind acb_gamma, acb_rgamma and acb_lgamma. Real arguments are passed to the real functions (see The gamma function of a real ball); otherwise the functions use a tabulated Taylor series near the real axis and the Stirling series elsewhere, as described in The gamma function.
The principal branch of log-gamma#
The function computed by acb_hypgeom_lgamma is not with the principal logarithm. It is the analytic continuation of from the positive real axis to , which is the convention of most computer algebra systems and of the DLMF [NIST2012, §5.4]: it satisfies exactly (not only modulo ), and its imaginary part grows like instead of staying in . The two functions differ by , where the integer changes along curves where is an odd multiple of . On the branch cut, the value is the limit from the upper half-plane.
Computing this branch requires more than a logarithm of :
- The Stirling series gives directly for of large modulus in the right half-plane. Its argument reduction needs the log-rising factorial with the correct multiple of , which
acb_hypgeom_log_rising_uicomputes with Hare's algorithm [Hare1997]. - The reflection formula for the left half-plane becomes , where must be the analytic branch computed by
acb_log_sin_pi. - Near the real axis at moderate precision, the Taylor series of is used for with real part in about ; the branch of applied to it is fixed with a table of the lines where crosses .
Example#
At the principal branch of and the principal logarithm of differ by :
#include <flint/acb.h>
#include <flint/acb_hypgeom.h>
int main(void)
{
acb_t z, y, t;
acb_init(z);
acb_init(y);
acb_init(t);
acb_set_d_d(z, -10.25, 0.5);
acb_hypgeom_gamma(y, z, 64);
flint_printf("gamma(z) = "); acb_printn(y, 15, 0); flint_printf("\n");
acb_hypgeom_lgamma(y, z, 64);
flint_printf("lgamma(z) = "); acb_printn(y, 15, 0); flint_printf("\n");
acb_hypgeom_gamma(t, z, 64);
acb_log(t, t, 64);
flint_printf("log(gamma(z)) = "); acb_printn(t, 15, 0); flint_printf("\n");
/* the difference is 2 pi i k */
acb_sub(t, y, t, 64);
acb_const_pi(y, 64);
acb_mul_2exp_si(y, y, 1);
acb_div(t, t, y, 64);
flint_printf("difference / (2 pi) = "); acb_printn(t, 15, 0); flint_printf("\n");
acb_hypgeom_rgamma(y, z, 64);
flint_printf("rgamma(z) = "); acb_printn(y, 15, 0); flint_printf("\n");
acb_clear(z);
acb_clear(y);
acb_clear(t);
flint_cleanup();
return 0;
}gamma(z) = [7.08331784482241e-8 +/- 3.66e-23] + [-1.88626361829666e-7 +/- 2.32e-22]*I lgamma(z) = [-15.4175381117796 +/- 4.86e-15] + [-32.6274954179361 +/- 2.24e-14]*I log(gamma(z)) = [-15.4175381117796 +/- 4.86e-15] + [-1.21156888203815 +/- 4.69e-15]*I difference / (2 pi) = [+/- 2.62e-19] + [-5.00000000000000 +/- 1.09e-18]*I rgamma(z) = [1744778.02581992 +/- 4.92e-9] + [4646284.95319217 +/- 4.09e-9]*I
is small here because is close to the negative real axis between two poles; , which is entire, is large.
References#
- [NIST2012] National Institute of Standards and Technology, Digital Library of Mathematical Functions (2012), https://dlmf.nist.gov/
- [Hare1997] D. E. G. Hare. Computing the principal branch of log-Gamma. Journal of Algorithms 25:2 (1997), 221–236. https://doi.org/10.1006/jagm.1997.0881
The FLINT team, “The gamma function of a complex ball (acb_hypgeom.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/acb_hypgeom/gamma.html (generated 2026-11-02).
@misc{flint-doc-acb-hypgeom-gamma,
author = {{The FLINT team}},
title = {{The gamma function of a complex ball (acb\_hypgeom.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/acb_hypgeom/gamma.html},
note = {Generated 2026-11-02}
}