FLINT3.7.0-dev

The generalized hypergeometric function

Synopsis#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)source

Sets res to the generalized hypergeometric function pFq(a1,…,ap;b1,…,bq;z){}_pF_q(a_1, \ldots, a_p; b_1, \ldots, b_q; z), or the regularized function pFq/(Γ(b1)⋯Γ(bq)){}_pF_q / (\Gamma(b_1) \cdots \Gamma(b_q)) if regularized is nonzero.

The orders (p,q)=(0,0),(1,0),(0,1),(1,1),(2,1)(p, q) = (0,0), (1,0), (0,1), (1,1), (2,1) are passed to acb_exp, the power (1−z)−a(1-z)^{-a}, 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 p≤qp \le q and for p=q+1p = q+1, ∣z∣<1|z| < 1, and gives a finite result for p>q+1p > q+1 only when the series terminates. Parameters that occur in both aa and bb are not removed (except a single upper parameter equal to 1, which cancels the k!k!); removing them first saves time. See The generalized hypergeometric function.

acb_hypgeom_pfq computes

pFq(a1,…,ap;b1,…,bq;z)=∑k=0∞(a1)k⋯(ap)k(b1)k⋯(bq)kzkk!{}_pF_q(a_1,\ldots,a_p;b_1,\ldots,b_q;z) = \sum_{k=0}^\infty \frac{(a_1)_k\cdots(a_p)_k}{(b_1)_k\cdots(b_q)_k} \frac{z^k}{k!}

for complex ball parameters and argument, or the regularized function pFq=pFq/(Γ(b1)⋯Γ(bq)){}_p\mathbf{F}_q = {}_pF_q/(\Gamma(b_1)\cdots\Gamma(b_q)) 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.

AlgorithmHypergeometric functionsThe general machinery for hypergeometric functions in ball arithmetic — convergent series with rigorous tail bounds (also for power series parameters), asymptotic expansions with Olver's error bounds, the choice between them by estimated cancellation, connection formulas and regularization, and the summation algorithms (forward recurrence, rectangular splitting, binary splitting, fast multipoint evaluation, bit-burst continuation).

Dispatch#

(p,q)(p, q)FunctionImplemented by
(0,0)(0, 0)eze^zacb_exp
(1,0)(1, 0)(1−z)−a(1-z)^{-a}acb_pow
(0,1)(0, 1)0F1(b;z){}_0F_1(b; z)acb_hypgeom_0f1
(1,1)(1, 1)1F1(a;b;z){}_1F_1(a; b; z)acb_hypgeom_m
(2,1)(2, 1)2F1(a1,a2;b;z){}_2F_1(a_1, a_2; b; z)acb_hypgeom_2f1
otherthe seriesacb_hypgeom_pfq_direct

For the first five orders, all zz are supported (with the branch cut [1,∞)[1, \infty) for p=q+1p = q + 1). 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 p≤qp \le q and all zz (the series is entire), although large ∣z∣|z| needs many terms and a high precision to overcome the cancellation, since no asymptotic expansion is implemented for general orders;
  • a finite result for p=q+1p = q + 1 and ∣z∣<1|z| < 1; the closer ∣z∣|z| is to 1, the more terms are needed, and no analytic continuation to ∣z∣≥1|z| \ge 1 is implemented for general orders;
  • a finite result for p>q+1p > q + 1 only if the series terminates, that is, if some aia_i 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 k!k!; other parameters that occur among both the aia_i and the bjb_j 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 1/Γ(bj)1/\Gamma(b_j) cancel the poles.

Example#

The dilogarithm is Li⁡2(z)=z 3F2(1,1,1;2,2;z)\operatorname{Li}_2(z) = z\, {}_3F_2(1,1,1;2,2;z); a 3F1{}_3F_1 with an upper parameter −3-3 is a polynomial even though p>q+1p > q + 1; and 1F2(1;−2,3;z){}_1F_2(1; -2, 3; z) is undefined while its regularized version is not:

Exampleacb_hypgeom_pfq_cases.cchecked by make checkdoc
#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;
}
Output
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 3F1(−3,2,5;7;4)=−3513/7{}_3F_1(-3,2,5;7;4) = -3513/7 is summed exactly up to rounding. In the regularized 1F2(1;−2,3;z){}_1\mathbf{F}_2(1;-2,3;z) the terms with k≤2k \le 2 vanish, because 1/Γ(−2+k)=01/\Gamma(-2+k) = 0, and the remaining terms sum to (1)3 z33! Γ(6) 1F2(4;6,4;z)=z3120 0F1(6;z)\frac{(1)_3\, z^3}{3!\,\Gamma(6)}\,{}_1F_2(4; 6, 4; z) = \frac{z^3}{120}\,{}_0F_1(6; z).

Cite this page

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).