Hypergeometric functions
- Cost
- N terms of a series at p bits — O(N) full multiplications forward, O(N^{1/2}) full and O(N) scalar multiplications by rectangular splitting, O(M(p) log² p) by binary splitting for arguments with O(1) bits, and O(M(p) log² p) for any argument with the bit-burst algorithm (holonomic functions).
A hypergeometric series is a series whose term ratio is a rational function of . In standard form,
Most classical special functions are hypergeometric series, or finite combinations of such series with exponential, power and gamma function prefactors. Evaluating them rigorously to arbitrary precision for all complex parameters and arguments requires three ingredients: the convergent series with a bound for the remainder, asymptotic expansions with error bounds for large arguments, and transformations and connection formulas that map the remaining cases to one of the first two. The implementation in acb_hypgeom is described in Johansson [Joh2016], from which the error bounds below are taken; the summation algorithms are surveyed in [Joh2014a].
Throughout this section,
so that is with the extra lower parameter . This is the convention of the low-level functions acb_hypgeom_pfq_sum and acb_hypgeom_pfq_direct.
Convergent series#
If , the series converges for all , and the terms eventually decrease faster than geometrically; if , it converges for . A bound for the tail in terms of the first omitted term follows from a bound for the term ratio.
Theorem 1 (Tail bound). Let and with for all , and let
If , then .
Proof. For , . Since , for (adding a positive real number to a number with positive real part increases its modulus). Hence
so for all , and the tail is bounded by .
acb_hypgeom_pfq_bound_factor computes with upper bounds in mag_t arithmetic, pairing the upper parameter with the lower parameter ; is infinite if , if some , or if . The bound can therefore be infinite for a small even if the series converges; the number of terms must be large enough that the terms have started to decrease. acb_hypgeom_pfq_direct sums terms with acb_hypgeom_pfq_sum, which also returns , and adds to the radius. If is exactly zero, the series has terminated and no error is added; this is how polynomials such as with a nonpositive integer upper parameter are computed for any , and .
Power series parameters#
The same principle gives bounds for each coefficient of when the parameters and the argument are themselves power series, which is how derivatives with respect to parameters and limits at singular parameter values are computed. Write for the coefficient of in , , , if for all , and .
Lemma 2. For power series and with ,
Proof. The first two follow from and the triangle inequality. For the third, write with ; then and , where the right side is expanded as a power series in .
Theorem 3. If and for all , let
If , then coefficientwise.
The proof is that of Theorem 1, with Lemma 2 in place of the scalar inequalities. In the implementation (acb_hypgeom_pfq_series_direct), sums and products of the majorant series are computed with point-valued upper bounds for the absolute values, so no interval arithmetic is needed; for a lower bound for and upper bounds for the other coefficients are used.
Number of terms and working precision#
acb_hypgeom_pfq_choose_n chooses by simulating the term magnitudes in double precision: it stops when the current term is prec bits smaller than the largest term seen so far, since the cancellation between large terms has to be compensated anyway. This also picks a sensible truncation point for divergent asymptotic series (where the terms decrease and then grow), stops at the end of a terminating series, and steps over parameters close to nonpositive integers. The functions built on the series also estimate the cancellation and raise the working precision: the sum of a series whose largest term is times its value loses about bits. For example with has terms of size up to about but a value of size , so Kummer's transformation is applied first, and loses about bits for negative .
Summation algorithms#
Let with polynomials and (absorbing into ). acb_hypgeom_pfq_sum and the variants for rational parameters in Sums of hypergeometric series with rational parameters choose among four ways to compute .
Forward recurrence. Compute and the partial sums term by term: multiplications and divisions at full precision. Divisions can be delayed by accumulating numerators and denominators separately (as arb_hypgeom_sum_fmpq_arb_forward does). This is best for few terms or when the parameters are full-precision numbers.
Rectangular splitting. When the parameters are short (integers or rationals with small numerators and denominators) but is a full-precision number, the expensive operations are the multiplications by . Writing the sum in Horner form backwards,
and grouping the powers of into blocks of length , the sum becomes a polynomial in whose coefficients are polynomials in of degree less than with short coefficients. With precomputed, the full multiplications number about , and the remaining operations are multiplications and divisions by short numbers. This is Smith's method of concurrent series [Smi1989], a variant of the Paterson–Stockmeyer algorithm for polynomial evaluation [PS1973]; Johansson [Joh2014b] generalizes it to parameters that are themselves full-precision numbers by expanding the products of consecutive factors as polynomials in the parameter. acb_hypgeom_pfq_sum_rs applies it with (at most 150), and arb_hypgeom_sum_fmpq_arb_rs combines up to 8 consecutive term ratios over a common integer denominator.
Binary splitting. The recurrence
gives from the product of matrices, which binary splitting computes as a balanced product tree (Binary splitting and product trees) [Bre1976; CC1988; BZ2011]. If and the parameters have bits, the entries of a subproduct of matrices have bits, and the whole product costs ; for -bit precision with terms, this is , quasi-linear in . If has bits, the entries grow to bits after few levels and the method degrades to full multiplications. In complex ball arithmetic, binary splitting also limits the overestimation of the radii (the wrapping effect), since each number goes through only operations, so acb_hypgeom_pfq_sum prefers it to the forward recurrence for even for long parameters. acb_hypgeom_pfq_sum_bs_invz puts into the denominators, which helps when is short, as in asymptotic expansions at integer arguments.
Fast multipoint evaluation. If and have degree , the product of the first matrices can be computed as a matrix of polynomials of degree in the shift ; evaluating it at the points with fast multipoint evaluation and multiplying the resulting matrices gives the whole product with full-precision operations, instead of full and scalar operations [CC1988; BGS2007]. acb_hypgeom_pfq_sum_fme implements this baby-step giant-step method for , using product trees for the evaluation (_acb_poly_evaluate_vec_fast_precomp). The numerical stability of the polynomial arithmetic in ball arithmetic is poorer, so it pays off only at high precision (from 1500 bits, for many terms).
acb_hypgeom_pfq_sum uses rectangular splitting when the parameters are short compared to the precision (binary splitting if moreover is short), fast multipoint evaluation for many terms at high precision, and otherwise binary splitting or, for at most 8 terms, the forward recurrence. The power series versions (acb_hypgeom_pfq_series_sum_forward, _bs, _rs) perform the same algorithms with truncated power series arithmetic.
The bit-burst algorithm#
Binary splitting is quasi-linear only for short arguments. For a holonomic function — one that satisfies a linear differential equation with polynomial coefficients, like every — the bit-burst algorithm [CC1990; vdH1999; Mez2010] removes this restriction. Write the -bit argument as where is truncated to bits. The Taylor coefficients of at satisfy a recurrence with polynomial coefficients in and , and the step from to needs only terms of a series whose argument has bits and magnitude at most . The total size of the numbers in the binary splitting tree of each step is therefore , and each step costs (evaluating the matrix of a fundamental system of solutions); with steps this gives overall. The error bounds for the local Taylor series come from Cauchy majorants of the differential equation [Hoe2001; vdH1999].
FLINT uses the bit-burst algorithm for the dilogarithm at very high precision (acb_hypgeom_dilog_bitburst, see The dilogarithm), for the error function and the incomplete gamma function with rational above 30000 bits (arb_hypgeom_erf_bb, see Error functions, incomplete gamma functions and exponential integrals), and in a simple form (one or two continuation steps with Taylor series, without the doubling of bits) for the corner case of (The Gauss hypergeometric function). The elementary functions and constants, which are the most important holonomic functions, are covered in Elementary functions and Mathematical constants.
Asymptotic expansions#
For large the convergent series needs about terms and suffers from cancellation of order . Asymptotic expansions then converge quickly in the sense that the first terms decrease rapidly, but they diverge, so the error has to be bounded explicitly for each truncation. All confluent hypergeometric functions reduce to the function , the confluent hypergeometric function of the second kind with its principal branch cut on . With ,
The error term is bounded following Olver [NIST2012, §13.7], with a case distinction according to the region in which lies; the formula for the bound increases with , so if is in two regions the larger index can be used. Let .
- If , then .
- Otherwise, if , or and , then .
- Otherwise, if , then .
- Otherwise the bound is infinite.
With the auxiliary quantities
the error is bounded by
acb_hypgeom_u_asymp evaluates this bound with mag_t arithmetic, chooses the number of terms with acb_hypgeom_pfq_choose_n (raising the target by the size of the exponential factor), and sums the series in powers of with acb_hypgeom_pfq_sum_invz. If or is a nonpositive integer, the series terminates and is exact, for every .
The Bessel, Airy, error, incomplete gamma, exponential and trigonometric integral and Coulomb functions all use this expansion through their representations by . The Airy functions have dedicated bounds, given in Asymptotic expansions.
Confluent hypergeometric functions#
The convergent and the asymptotic expansions are tied together by connection formulas. For and [NIST2012, 13.2.42],
and for all
which is equivalent to [NIST2012, 13.2.41] but simpler in form. The first gives for small from two convergent series (acb_hypgeom_u_1f1); the second gives for large from two asymptotic series (acb_hypgeom_m_asymp).
Choosing between them. For below 4 the convergent series is used, and for the asymptotic one. In between, acb_hypgeom_m and acb_hypgeom_u compare the accuracy that the asymptotic expansion can reach, about bits (the smallest term of is about for small parameters), with the accuracy of the convergent series after the estimated cancellation, and choose the method and the working precision accordingly. If the asymptotic expansion reaches the target precision it is preferred, since it is cheaper. For large parameters the asymptotic expansion is useless, and the convergent series needs a very high working precision; for real arguments the functions then try rigorous numerical integration (Numerical integration).
Limits at integer parameters. The formula for has removable singularities at integer . acb_hypgeom_u_1f1 handles this case by evaluating the formula with replaced by the power series and dividing out the zero of the denominator , using the power series algorithms and tail bounds above; the regularized functions are summed so that the factor vanishes for the terms that would divide by zero. The same technique gives and at integer , and the limits of the transformations.
Numerical integration#
For large real parameters, where both expansions are slow, the integral representations
and the analogous ones for , , and are evaluated with the rigorous integration of acb_calc_integrate [Joh2018a]. The integrands are smooth and positive for the parameter ranges in which the functions are implemented (, and so on), and the cost of the integration grows only slowly with the parameters. acb_hypgeom_m, acb_hypgeom_u, acb_hypgeom_2f1, acb_hypgeom_gamma_upper, acb_hypgeom_bessel_i and acb_hypgeom_bessel_k call the integration functions of arb_hypgeom when their other methods give less than half of the requested accuracy and all arguments are real and below , and keep the better enclosure.
Use in FLINT#
- Series summation:
acb_hypgeom_pfq_sumand its variantsacb_hypgeom_pfq_sum_forward,acb_hypgeom_pfq_sum_rs,acb_hypgeom_pfq_sum_bs,acb_hypgeom_pfq_sum_fme,acb_hypgeom_pfq_sum_invz; for power seriesacb_hypgeom_pfq_series_sumand its variants; for rational parametersarb_hypgeom_sum_fmpq_arbandarb_hypgeom_sum_fmpq_imag_arb. - Tail bounds:
acb_hypgeom_pfq_bound_factor,acb_hypgeom_pfq_direct,acb_hypgeom_pfq_series_direct; choice of the number of terms:acb_hypgeom_pfq_choose_n,acb_hypgeom_pfq_series_choose_n. - Asymptotic expansions:
acb_hypgeom_u_asympand everything built on it (acb_hypgeom_m_asymp,acb_hypgeom_0f1_asymp,acb_hypgeom_bessel_j_asymp,acb_hypgeom_bessel_k_asymp,acb_hypgeom_erf_asymp,acb_hypgeom_gamma_upper_asymp,acb_hypgeom_ei_asymp,acb_hypgeom_si_asymp, the Coulomb wave functions). - Connection formulas and the choice of method:
acb_hypgeom_u,acb_hypgeom_u_1f1,acb_hypgeom_m,acb_hypgeom_0f1,acb_hypgeom_pfq. - The top-level page Evaluating special functions maps every function family to the methods it uses; the generic multiple-precision floating-point type
mp_realhas its own hypergeometric binary splitting for constants, see Floating-point arithmetic in FLINT.
Referenced from#
- acb_hypgeom.h (module)
acb_hypgeom_m_asymp,acb_hypgeom_m_1f1,acb_hypgeom_m,acb_hypgeom_1f1acb_hypgeom_u_asympacb_hypgeom_pfq_bound_factoracb_hypgeom_pfq_series_direct- The generalized hypergeometric function
- Bessel, Airy and Coulomb wave functions (algorithm)
- The dilogarithm (algorithm)
- Error functions, incomplete gamma functions and exponential integrals (algorithm)
- The Gauss hypergeometric function (algorithm)
- Sums of hypergeometric series with rational parameters (algorithm)
- Special functions (overview)
- Evaluating special functions (overview)
- Error functions of a real ball
- arb_hypgeom.h (module)
- Hypergeometric sums with rational parameters
- gr_special.h (module)
References#
- [Joh2016] F. Johansson, "Computing hypergeometric functions rigorously", preprint (2016), https://arxiv.org/abs/1606.06977
- [Joh2014a] F. Johansson, Fast and rigorous computation of special functions to high precision, PhD thesis, RISC, Johannes Kepler University, Linz, 2014. https://fredrikj.net/thesis/
- [Smi1989] D. M. Smith. Efficient multiple-precision evaluation of elementary functions. Mathematics of Computation 52 (1989), 131–134. https://doi.org/10.1090/S0025-5718-1989-0971406-0
- [PS1973] M. S. Paterson and L. J. Stockmeyer, "On the number of nonscalar multiplications necessary to evaluate polynomials", SIAM J. Comput (1973)
- [Joh2014b] F. Johansson, "Evaluating parametric holonomic sequences using rectangular splitting", ISSAC 2014, 256-263. https://doi.org/10.1145/2608628.2608629
- [Bre1976] R. P. Brent. The complexity of multiple-precision arithmetic. In R. S. Anderssen and R. P. Brent (eds.), The Complexity of Computational Problem Solving, University of Queensland Press, 1976, 126–165.
- [CC1988] D. V. Chudnovsky and G. V. Chudnovsky. Approximations and complex multiplication according to Ramanujan. In Ramanujan Revisited, Academic Press, 1988, 375–472.
- [BZ2011] R. P. Brent and P. Zimmermann, Modern Computer Arithmetic, Cambridge University Press (2011), http://www.loria.fr/~zimmerma/mca/pub226.html
- [BGS2007] A. Bostan, P. Gaudry and É. Schost, "Linear recurrences with polynomial coefficients and application to integer factorization and Cartier–Manin operator", SIAM Journal on Computing 36 (2007), 1777–1806
- [CC1990] D. V. Chudnovsky and G. V. Chudnovsky. Computer algebra in the service of mathematical physics and number theory. In Computers in Mathematics (Stanford, 1986), Lecture Notes in Pure and Applied Mathematics 125, Dekker, 1990, 109–232.
- [vdH1999] J. van der Hoeven. Fast evaluation of holonomic functions. Theoretical Computer Science 210:1 (1999), 199–215. https://doi.org/10.1016/S0304-3975(98)00102-9
- [Mez2010] M. Mezzarobba. NumGfun: a package for numerical and analytic computation with D-finite functions. ISSAC 2010, 139–146. https://doi.org/10.1145/1837934.1837965
- [Hoe2001] J. van der Hoeven. "Fast evaluation of holonomic functions near and in regular singularities", Journal of Symbolic Computation, 31(6):717-743 (2001).
- [NIST2012] National Institute of Standards and Technology, Digital Library of Mathematical Functions (2012), https://dlmf.nist.gov/
- [Joh2018a] F. Johansson, "Numerical integration in arbitrary-precision ball arithmetic", preprint (2018), https://arxiv.org/abs/1802.07942
The FLINT team, “Hypergeometric functions,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/hypergeometric.html (generated 2026-11-02).
@misc{flint-doc-algorithms-special-functions-hypergeometric,
author = {{The FLINT team}},
title = {{Hypergeometric functions}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/hypergeometric.html},
note = {Generated 2026-11-02}
}