The generalized hypergeometric function
#include <flint/acb_hypgeom.h>void acb_hypgeom_pfq(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, int regularized, slong prec)sourceSets res to the generalized hypergeometric function , or the regularized function if regularized is nonzero.
The orders are passed to acb_exp, the power , acb_hypgeom_0f1, acb_hypgeom_m and acb_hypgeom_2f1, which implement analytic continuation and asymptotic expansions. All other orders use direct summation of the series with acb_hypgeom_pfq_direct (with a power series variant for regularized functions whose lower parameters may be nonpositive integers), which converges for and for , , and gives a finite result for only when the series terminates. Parameters that occur in both and are not removed (except a single upper parameter equal to 1, which cancels the ); removing them first saves time. See The generalized hypergeometric function.
acb_hypgeom_pfq computes
for complex ball parameters and argument, or the regularized function if regularized is nonzero. arb_hypgeom_pfq is the real version. The function is a front end: it recognizes the orders for which this module has an implementation with analytic continuation and asymptotic expansions, and sums the series directly with a rigorous tail bound otherwise.
Dispatch#
| Function | Implemented by | |
|---|---|---|
acb_exp | ||
acb_pow | ||
acb_hypgeom_0f1 | ||
acb_hypgeom_m | ||
acb_hypgeom_2f1 | ||
| other | the series | acb_hypgeom_pfq_direct |
For the first five orders, all are supported (with the branch cut for ). For the other orders the function sums the defining series with acb_hypgeom_pfq_direct, choosing the number of terms with acb_hypgeom_pfq_choose_n and bounding the remainder with acb_hypgeom_pfq_bound_factor. This gives
- a finite result for and all (the series is entire), although large needs many terms and a high precision to overcome the cancellation, since no asymptotic expansion is implemented for general orders;
- a finite result for and ; the closer is to 1, the more terms are needed, and no analytic continuation to is implemented for general orders;
- a finite result for only if the series terminates, that is, if some is a nonpositive integer; otherwise the series diverges and the result is indeterminate.
If an upper parameter is exactly 1, it is removed together with the ; other parameters that occur among both the and the are not cancelled, which costs time, and the caller can remove them beforehand. With regularized set and a lower parameter that may be a nonpositive integer, the series is summed with power series arithmetic (acb_hypgeom_pfq_series_direct) so that the vanishing factors cancel the poles.
Example#
The dilogarithm is ; a with an upper parameter is a polynomial even though ; and is undefined while its regularized version is not:
#include <flint/acb.h>
#include <flint/acb_hypgeom.h>
int main(void)
{
acb_ptr a, b;
acb_t z, r;
a = _acb_vec_init(3);
b = _acb_vec_init(2);
acb_init(z);
acb_init(r);
/* Li_2(1/2) = (1/2) 3F2(1,1,1; 2,2; 1/2) */
acb_set_ui(a + 0, 1); acb_set_ui(a + 1, 1); acb_set_ui(a + 2, 1);
acb_set_ui(b + 0, 2); acb_set_ui(b + 1, 2);
acb_set_d(z, 0.5);
acb_hypgeom_pfq(r, a, 3, b, 2, z, 0, 64);
acb_mul(r, r, z, 64);
flint_printf("z 3F2(1,1,1;2,2;z) = "); acb_printn(r, 18, 0); flint_printf("\n");
acb_hypgeom_dilog(r, z, 64);
flint_printf("Li2(z) = "); acb_printn(r, 18, 0); flint_printf("\n");
/* a terminating series with p > q + 1 */
acb_set_si(a + 0, -3); acb_set_ui(a + 1, 2); acb_set_ui(a + 2, 5);
acb_set_ui(b + 0, 7);
acb_set_ui(z, 4);
acb_hypgeom_pfq(r, a, 3, b, 1, z, 0, 64);
flint_printf("3F1(-3,2,5;7;4) = "); acb_printn(r, 18, 0); flint_printf("\n");
/* the same series without termination diverges */
acb_set_d(a + 0, -2.5);
acb_set_d(z, 0.125);
acb_hypgeom_pfq(r, a, 3, b, 1, z, 0, 64);
flint_printf("3F1(-2.5,2,5;7;z) = "); acb_printn(r, 18, 0); flint_printf("\n");
/* regularized: a lower parameter at a pole of the gamma function */
acb_set_ui(a + 0, 1);
acb_set_si(b + 0, -2); acb_set_ui(b + 1, 3);
acb_set_d(z, 0.5);
acb_hypgeom_pfq(r, a, 1, b, 2, z, 1, 64);
flint_printf("1F2~(1;-2,3;z) = "); acb_printn(r, 18, 0); flint_printf("\n");
acb_hypgeom_pfq(r, a, 1, b, 2, z, 0, 64);
flint_printf("1F2(1;-2,3;z) = "); acb_printn(r, 18, 0); flint_printf("\n");
_acb_vec_clear(a, 3);
_acb_vec_clear(b, 2);
acb_clear(z);
acb_clear(r);
flint_cleanup();
return 0;
}z 3F2(1,1,1;2,2;z) = [0.58224052646501251 +/- 5.21e-18] Li2(z) = [0.582240526465012506 +/- 2.06e-19] 3F1(-3,2,5;7;4) = [-501.857142857142857 +/- 2.91e-16] 3F1(-2.5,2,5;7;z) = nan + nan*I 1F2~(1;-2,3;z) = [0.00113163791418884985 +/- 2.03e-21] 1F2(1;-2,3;z) = nan + nan*I
The polynomial is summed exactly up to rounding. In the regularized the terms with vanish, because , and the remaining terms sum to .
The FLINT team, “The generalized hypergeometric function (acb_hypgeom.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/acb_hypgeom/pfq.html (generated 2026-11-02).
@misc{flint-doc-acb-hypgeom-pfq,
author = {{The FLINT team}},
title = {{The generalized hypergeometric function (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/pfq.html},
note = {Generated 2026-11-02}
}