acb_hypgeom.h
#include <flint/acb_hypgeom.h>This module evaluates hypergeometric functions of complex arguments given as balls (acb_t) or as complex power series (acb_poly_t), with rigorous error bounds. The generalized hypergeometric function is defined by the series
interpreted by analytic continuation (or as a formal series together with an asymptotic expansion) where it does not converge. In a wider sense, "hypergeometric functions" are linear combinations of such functions with prefactors that are products of exponentials, powers and gamma functions. This covers most classical special functions, and this module implements the gamma function and rising factorials, the confluent functions {}_0F_1, {}_1F_1 and U, error functions and Fresnel integrals, incomplete gamma and beta functions, exponential, sine and cosine integrals, Bessel, Airy and Coulomb wave functions, the Gauss function {}_2F_1, Legendre functions, orthogonal polynomials, spherical harmonics and the dilogarithm. The real versions are in arb_hypgeom, which calls this module for most functions, and the generic interface gr_special calls both for its real and complex ball contexts.
Each function chooses between convergent series, asymptotic expansions, transformation formulas, analytic continuation and, for real arguments, numerical integration, and sets its working precision from an estimate of the cancellation; the algorithms and error bounds are described in Hypergeometric functions, and Evaluating special functions maps each function to its methods. The guide Using acb_hypgeom explains the conventions with examples.
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).Guides#
Conventions#
- Enclosures. Every function returns a ball containing the value of the function at every point of the input balls. If the function is undefined somewhere in the input (a pole, or an input that straddles a branch cut in a way the function cannot handle), or if no finite enclosure could be computed, the output is indeterminate (see
acb_indeterminate). A wide or indeterminate output for a valid input usually means that the precision is too low for the size of the parameters; increasingprechelps. - Precision.
precis the target precision. The functions estimate the cancellation in the series they use and increase the working precision internally, and reduce it to what the accuracy of the input justifies. For inexact input they usually evaluate at the midpoint and bound the propagated error with derivative bounds. - Branch cuts. Multivalued functions use the principal branch, with the branch cut on (-\infty, 0] for functions built from \log z and z^a (U, \operatorname{Ei}, \operatorname{Ci}, Coulomb functions, the log-gamma function) and on [1, +\infty) for functions built from \log(1-z) ({}_2F_1, the dilogarithm). On a cut the value follows
acb_log, which is continuous from the upper half-plane on (-\infty, 0); for a cut on (1, +\infty) this means the limit from the lower half-plane. The conventions for the exponential and trigonometric integrals match Mathematica. - Regularization. An
intargumentregularized(orflagsfor {}_2F_1) selects the regularized function, divided by the gamma functions of the lower parameters so that it is entire in them; the regularized function is defined at the nonpositive integers where the ordinary one has poles. - Aliasing and optional outputs. Inputs and outputs may be the same object unless stated otherwise. Functions with several outputs accept
NULLfor unwanted outputs. The underscore power series functions require positive lengths, write exactlylencoefficients and do not allow the output to overlap the input. - Wrappers. For real input, several functions call the faster real implementation in
arb_hypgeom(gamma, rising factorials, error function, Legendre polynomials).
Rising factorials#
void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, ulong n, slong prec)void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, ulong n, slong prec)void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, ulong n, slong prec)void acb_hypgeom_rising_ui(acb_t res, const acb_t x, ulong n, slong prec)void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, slong prec)Sets res to the rising factorial (x)_n = x(x+1)\cdots(x+n-1); acb_hypgeom_rising allows any complex n and computes \Gamma(x+n)/\Gamma(x).
void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, ulong n, ulong m, slong len, slong prec)Sets the vector res of length len to the coefficients of the polynomial (x + t)_n \in \mathbb{C}[t], truncated if \mathit{len} < n+1 and padded with zeros if \mathit{len} > n+1.
void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, ulong n, slong prec)Sets res to the log-rising factorial \log\,(x)_n = \sum_{k=0}^{n-1} \log(x+k), the sum of principal logarithms, which differs from the principal logarithm of (x)_n by a multiple of 2\pi i.
Sets the vector res to the coefficients of \log\,(x+t)_n as a power series in t, truncated to length len, with the constant term as in acb_hypgeom_log_rising_ui.
Gamma function#
The algorithms for the gamma function are described in The gamma function.
void acb_hypgeom_gamma(acb_t res, const acb_t x, slong prec)Sets res to the gamma function \Gamma(x). The result is indeterminate if x contains a pole.
void acb_hypgeom_rgamma(acb_t res, const acb_t x, slong prec)Sets res to the reciprocal gamma function 1/\Gamma(x), which is entire.
void acb_hypgeom_lgamma(acb_t res, const acb_t x, slong prec)Sets res to the principal branch of the log-gamma function \log \Gamma(x), which is analytic except on the branch cut (-\infty, 0] and differs from \log(\Gamma(x)) by a multiple of 2\pi i.
void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, slong N, slong prec)Sets s to \sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1}), the sum in the Stirling series truncated before the term of index N, using Horner's scheme or the improved algorithm with splitting parameter K (0 to choose it), as arb_hypgeom_gamma_stirling_sum_horner and arb_hypgeom_gamma_stirling_sum_improved do for real z. No bound for the truncation error is added.
void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, slong prec)Sets res to \Gamma(x), or 1/\Gamma(x) if reciprocal is nonzero, computed with the Stirling series after argument reduction by a rising factorial and, for real part below -5, the reflection formula. See arb_hypgeom_gamma_stirling and The Stirling series.
int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, slong prec)Attempts to compute \Gamma(x), or 1/\Gamma(x) if reciprocal is nonzero, with the tabulated Taylor series of 1/\Gamma(1+x) and argument reduction. Returns 1 on success and 0, without changing res, if x or prec is outside the supported range.
Generalized hypergeometric function#
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)Sets res to the generalized hypergeometric function {}_pF_q(a_1, \ldots, a_p; b_1, \ldots, b_q; z), or the regularized function {}_pF_q / (\Gamma(b_1) \cdots \Gamma(b_q)) if regularized is nonzero.
Confluent hypergeometric functions#
In this section U(a,b,z) is the confluent hypergeometric function of the second kind with the principal branch cut, and U^{*}(a,b,z) = z^a U(a,b,z), which tends to 1 as z \to \infty in the sector |\arg z| < 3\pi/2.
void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec)void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec)void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec)void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec)Sets res to Kummer's confluent hypergeometric function M(a,b,z) = {}_1F_1(a,b,z), or \mathbf{M}(a,b,z) = {}_1F_1(a,b,z)/\Gamma(b) if regularized is nonzero. acb_hypgeom_1f1 is the same function as acb_hypgeom_m.
void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong n, slong prec)Sets res to U^{*}(a,b,z) computed with n terms of the asymptotic series U^{*}(a,b,z) \sim {}_2F_0(a, a-b+1; ; -1/z), with a rigorous bound for the truncation error. Requires n \ge 0; n < 0 chooses the number of terms automatically.
int acb_hypgeom_u_use_asymp(const acb_t z, slong prec)Returns nonzero if the asymptotic series is expected to give U(a,b,z) to prec bits, namely if |z| > \mathit{prec} \log 2 or |z| > 2^{64} (assuming that a and b are small).
void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, slong len, slong prec)Sets res to U(a,b,z) as a power series truncated to length len, for power series a, b, z \in \mathbb{C}[[x]], using the connection formula with two {}_1F_1 series. If the constant term of b is an integer, one extra derivative is computed and the removable singularity is divided out; it is then assumed that the coefficient of x in b is nonzero. The output is indeterminate if the constant term of b is inexact and contains an integer.
Sets res to U(a,b,z) computed from the convergent series by the connection formula
If b is an integer the limit is computed with acb_hypgeom_u_1f1_series; the output is indeterminate if b is inexact and contains an integer.
Sets res to U(a,b,z).
void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec)void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec)void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec)Sets res to the confluent hypergeometric limit function {}_0F_1(a, z), or {}_0F_1(a,z)/\Gamma(a) if regularized is nonzero, using asymptotic expansions, direct summation, or an automatic choice.
Error functions and Fresnel integrals#
The representations and the choice of method for this section and the next two are described in Error functions, incomplete gamma functions and exponential integrals.
void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, slong prec)void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, slong prec)void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, slong prec, slong prec2)Sets res to \operatorname{erf}(z) computed respectively from
void acb_hypgeom_erf(acb_t res, const acb_t z, slong prec)Sets res to the error function \operatorname{erf}(z) = \frac{2}{\sqrt\pi} \int_0^z e^{-t^2} dt.
void acb_hypgeom_erf_propagated_error(mag_t re, mag_t im, const acb_t z)Sets re and im to upper bounds for the errors in the real and imaginary parts that result from replacing \operatorname{erf}(z) by \operatorname{erf} evaluated at the midpoint of z, using a bound for the first derivative \frac{2}{\sqrt\pi} e^{-z^2} on the ball.
void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the error function of the power series z, truncated to length len.
void acb_hypgeom_erfc(acb_t res, const acb_t z, slong prec)Sets res to the complementary error function \operatorname{erfc}(z) = 1 - \operatorname{erf}(z), avoiding the catastrophic cancellation of the subtraction when \operatorname{Re} z is large and positive.
void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the complementary error function of the power series z, truncated to length len.
void acb_hypgeom_erfi(acb_t res, const acb_t z, slong prec)Sets res to the imaginary error function \operatorname{erfi}(z) = -i\operatorname{erf}(iz), computed with acb_hypgeom_erf.
void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the imaginary error function of the power series z, truncated to length len.
void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, slong prec)Sets res1 to the Fresnel sine integral S(z) and res2 to the Fresnel cosine integral C(z); either output may be NULL. If normalized is 0, S(z) = \int_0^z \sin(t^2) dt and C(z) = \int_0^z \cos(t^2) dt; if normalized is 1, the integrands are \sin(\tfrac12 \pi t^2) and \cos(\tfrac12 \pi t^2), the convention of Abramowitz and Stegun and of the DLMF. The values are computed from \operatorname{erf}((1 \pm i) w), where w is z times a real constant, evaluated at the midpoint of z with a bound for the propagated error.
void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, slong zlen, int normalized, slong len, slong prec)void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, slong len, slong prec)Sets res1 and res2 to the Fresnel sine and cosine integrals of the power series z, truncated to length len. Either output may be NULL.
Incomplete gamma and beta functions#
void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec)void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec)void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec)void acb_hypgeom_gamma_upper_singular(acb_t res, slong s, const acb_t z, int regularized, slong prec)void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec)Sets res to the upper incomplete gamma function \Gamma(s,z) = \int_z^\infty t^{s-1} e^{-t} dt if regularized is 0, to Q(s,z) = \Gamma(s,z) / \Gamma(s) if regularized is 1, and to the generalized exponential integral z^{-s} \Gamma(s,z) = E_{1-s}(z) if regularized is 2 (mainly for internal use; acb_hypgeom_expint is the interface for E_s).
void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec)void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec)Sets res to the upper incomplete gamma function of the constant s and the power series z, truncated to length n, with regularized as in acb_hypgeom_gamma_upper.
void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec)Sets res to the lower incomplete gamma function \gamma(s,z) = \int_0^z t^{s-1} e^{-t} dt = \frac{z^s}{s} {}_1F_1(s, s+1, -z) if regularized is 0, to P(s,z) = \gamma(s,z) / \Gamma(s) if regularized is 1, and to \gamma^{*}(s,z) = z^{-s} P(s,z), which is entire in s and z, if regularized is 2.
void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec)void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec)Sets res to the lower incomplete gamma function of the constant s and the power series z, truncated to length n, with regularized as in acb_hypgeom_gamma_lower.
void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec)Sets res to the incomplete beta function B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1} dt, or the regularized incomplete beta function I(a,b;z) = B(a,b;z) / B(a,b;1) if regularized is nonzero.
void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, slong zlen, int regularized, slong n, slong prec)void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, slong n, slong prec)Sets res to B(a,b;z) (or I(a,b;z) if regularized is nonzero) for constants a and b and the power series z, truncated to length n.
Exponential and trigonometric integrals#
void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, slong prec)Sets res to the generalized exponential integral E_s(z) = z^{s-1} \Gamma(1-s, z), computed with acb_hypgeom_gamma_upper.
void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, slong prec)void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, slong prec)void acb_hypgeom_ei(acb_t res, const acb_t z, slong prec)Sets res to the exponential integral \operatorname{Ei}(z), computed respectively from
or by an automatic choice based on the expected accuracy of the two methods. The result is indeterminate if z contains zero.
void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the exponential integral of the power series z, truncated to length len.
void acb_hypgeom_si_asymp(acb_t res, const acb_t z, slong prec)void acb_hypgeom_si_1f2(acb_t res, const acb_t z, slong prec)void acb_hypgeom_si(acb_t res, const acb_t z, slong prec)Sets res to the sine integral \operatorname{Si}(z), computed respectively from
or by an automatic choice. Real input is passed to arb_hypgeom_si.
void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the sine integral of the power series z, truncated to length len.
void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, slong prec)void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, slong prec)void acb_hypgeom_ci(acb_t res, const acb_t z, slong prec)Sets res to the cosine integral \operatorname{Ci}(z), computed respectively from
or by an automatic choice. Positive real input is passed to arb_hypgeom_ci.
void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the cosine integral of the power series z, truncated to length len.
void acb_hypgeom_shi(acb_t res, const acb_t z, slong prec)Sets res to the hyperbolic sine integral \operatorname{Shi}(z) = -i \operatorname{Si}(iz), computed with acb_hypgeom_si.
void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the hyperbolic sine integral of the power series z, truncated to length len.
void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, slong prec)void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, slong prec)void acb_hypgeom_chi(acb_t res, const acb_t z, slong prec)Sets res to the hyperbolic cosine integral \operatorname{Chi}(z), computed respectively from
or by an automatic choice.
void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec)Sets res to the hyperbolic cosine integral of the power series z, truncated to length len.
void acb_hypgeom_li(acb_t res, const acb_t z, int offset, slong prec)Sets res to the logarithmic integral \operatorname{li}(z) = \operatorname{Ei}(\log(z)) if offset is zero, or the offset logarithmic integral \operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2) if offset is nonzero.
void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, slong zlen, int offset, slong len, slong prec)void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, slong len, slong prec)Sets res to the logarithmic integral (the offset version if offset is nonzero) of the power series z, truncated to length len.
Bessel functions#
The methods for the Bessel, Airy and Coulomb wave functions are described in Bessel, Airy and Coulomb wave functions.
void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec)Sets res to the Bessel function of the first kind J_\nu(z) computed with the asymptotic expansion of acb_hypgeom_u_asymp.
void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, slong prec)Sets res to J_\nu(z) computed from the convergent series
using J_{-n}(z) = (-1)^n J_n(z) for negative integer \nu.
void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, slong prec)Sets res to the Bessel function of the first kind J_\nu(z).
void acb_hypgeom_bessel_j_deriv_bound(mag_t res, const acb_t nu, const acb_t z, ulong d)Sets res to an upper bound, possibly crude, for |J_\nu^{(d)}(z)| (|J_\nu(z)| for d = 0). Implemented only for integer \nu, using for example |J_n^{(d)}(z)| \le e^{|\operatorname{Im} z|}; for non-integer \nu the bound is infinite.
void _acb_hypgeom_bessel_j_series(acb_ptr res, const acb_t nu, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_bessel_j_series(acb_poly_t res, const acb_t nu, const acb_poly_t z, slong len, slong prec)Sets res to J_\nu(z) for the constant \nu and the power series z, truncated to length len. Both functions call the generic _gr_poly_bessel_j_series with a complex ball context; as described for arb_hypgeom_bessel_j_series, the result is indeterminate if the constant term of z is an inexact ball containing zero.
void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, slong prec)Sets res to the Bessel function of the second kind
or for \nu = n an integer the limit
The output is indeterminate if \nu is inexact and contains an integer.
Sets res1 to J_\nu(z) and res2 to Y_\nu(z), computed together. The Hankel functions H_\nu^{(1)}(z), H_\nu^{(2)}(z) = J_\nu(z) \pm i Y_\nu(z) can be formed from them.
Modified Bessel functions#
void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec)void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec)void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, slong prec)void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec)Sets res to the modified Bessel function of the first kind I_\nu(z) = z^\nu (iz)^{-\nu} J_\nu(iz), computed respectively with the asymptotic expansion (see acb_hypgeom_bessel_j_asymp), the convergent series
or an automatic choice. acb_hypgeom_bessel_i_scaled computes e^{-z} I_\nu(z); the asymp and 0f1 versions compute the scaled function if scaled is nonzero. For real arguments with an inaccurate result, the automatic versions also try arb_hypgeom_bessel_i_integration.
void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec)Sets res to the modified Bessel function of the second kind
valid for all \nu and z \ne 0, using acb_hypgeom_u_asymp; or e^z K_\nu(z) if scaled is nonzero.
void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, slong len, slong prec)Sets res to K_\nu(z) (or e^z K_\nu(z) if scaled is nonzero) as a power series truncated to length len, for power series \nu, z \in \mathbb{C}[[x]], using
If the constant term of \nu is an integer, one extra derivative is computed and the singularity is removed (the coefficient of x in \nu must then be nonzero). The output is indeterminate if the constant term of \nu is inexact and contains an integer.
void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec)Sets res to K_\nu(z) (or e^z K_\nu(z) if scaled is nonzero) computed from
for \nu \notin \mathbb{Z}, and the limit computed with acb_hypgeom_bessel_k_0f1_series for \nu \in \mathbb{Z}. The output is indeterminate if \nu is inexact and contains an integer.
void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, slong prec)void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec)Sets res to the modified Bessel function of the second kind K_\nu(z), or to e^z K_\nu(z), choosing between the asymptotic expansion and the convergent series. For real arguments with an inaccurate result they also try arb_hypgeom_bessel_k_integration.
Airy functions#
The Airy functions \operatorname{Ai}(z) and \operatorname{Bi}(z) are linearly independent solutions of y'' - zy = 0; both are entire. For negative z both oscillate; for positive z the first decreases and the second increases exponentially. They can be expressed with Bessel functions of order \pm 1/3, but these formulas hold only piecewise (because of the Stokes phenomenon), so the module provides a dedicated implementation. The functions below compute (\operatorname{Ai}(z), \operatorname{Ai}'(z), \operatorname{Bi}(z), \operatorname{Bi}'(z)) together; any of the four outputs may be NULL, which saves work.
void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec)Computes the Airy functions with the convergent series at the origin truncated after n terms, including a bound for the truncation error.
void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec)Computes the Airy functions with the asymptotic expansions truncated after n terms, including a bound for the truncation error. The bounds and connection formulas are given in Asymptotic expansions.
Sets the outputs to upper bounds for |\operatorname{Ai}(z)|, |\operatorname{Ai}'(z)|, |\operatorname{Bi}(z)|, |\operatorname{Bi}'(z)| on the ball z, from first-order asymptotic expansions with error bounds. This is faster than calling acb_hypgeom_airy_asymp with n = 1.
void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong prec)Computes the Airy functions with an automatic choice of method.
MoreSets the vectors ai and bi to the Taylor coefficients of \operatorname{Ai} and \operatorname{Bi} at the point z, truncated to length len. Either output may be NULL; z must not alias the outputs. The expansions of the derivatives are obtained by computing one more coefficient and applying _acb_poly_derivative.
void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, slong len, slong prec)Sets the outputs to the Airy functions and their derivatives evaluated at the power series z, truncated to length len. Any of the outputs may be NULL.
Coulomb wave functions#
Coulomb wave functions are solutions of the Coulomb wave equation
the radial Schrödinger equation for a charged particle in a Coulomb potential 1/z, where \ell is the orbital angular momentum and \eta the Sommerfeld parameter. The standard solutions are F_\ell(\eta,z), regular at the origin, and G_\ell(\eta,z), irregular at the origin; the irregular solutions H^{\pm}_\ell(\eta,z) = G_\ell(\eta,z) \pm i F_\ell(\eta,z) are also used. They are special cases of confluent hypergeometric functions; the normalizations and connection formulas are discussed in [DYF1999], [Gas2018], [Mic2007] and [NIST2012, chapter 33]. Here the analytic continuations of all functions are defined so that the branch cut with respect to z is the negative real axis; precise definitions are given in [Fungrim] (topic "Coulomb wave functions"), whose formulas the implementation follows.
The functions below compute F_\ell(\eta,z), G_\ell(\eta,z), H^{+}_\ell(\eta,z) and H^{-}_\ell(\eta,z) together; any output may be NULL. The redundant functions H^{\pm} are provided because the linear combination of F and G suffers from cancellation in parts of the complex plane.
void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, slong prec)Sets F, G, Hpos, Hneg to the respective Coulomb wave functions. Any of the outputs may be NULL.
void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, slong len, slong prec)Sets F, G, Hpos, Hneg to the Taylor coefficients of the Coulomb wave functions at the point z, truncated to length len, using the differential equation to obtain the higher coefficients. Any of the outputs may be NULL.
void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, slong zlen, slong len, slong prec)void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, slong len, slong prec)Sets the outputs to the Coulomb wave functions evaluated at the power series z, truncated to length len. Any of the outputs may be NULL.
Gauss hypergeometric function#
The functions in this section compute the Gauss hypergeometric function
or, if the flag regularized (ACB_HYPGEOM_2F1_REGULARIZED) is set, the regularized function \mathbf{F}(z) = \mathbf{F}(a,b,c,z) = {}_2F_1(a,b,c,z) / \Gamma(c), which is entire in a, b and c. The branch cut is [1, +\infty); on the cut, the value is the limit from the lower half-plane. The algorithms are described in The Gauss hypergeometric function.
Bit flags for the flags argument of acb_hypgeom_2f1 and acb_hypgeom_2f1_transform, with the values 1, 2, 4, 8 and 16: compute the regularized function, and declare that a - b, a - c, b - c or a + b - c respectively is an exact integer.
void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, slong prec)Sets res to F(z), or \mathbf{F}(z) if flags contains ACB_HYPGEOM_2F1_REGULARIZED, with an automatic choice of algorithm. The other flags declare that a parameter difference is an exact integer even if the input balls are inexact, so that the correct limit is computed where a transformation formula is singular.
void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec)Sets res to F(z) (or \mathbf{F}(z)) by direct summation of the hypergeometric series, which converges for |z| < 1.
void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, slong len, slong prec)Sets res to F(z) (or \mathbf{F}(z)) for power series parameters and argument, truncated to length len, by direct summation of the hypergeometric series.
void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, slong prec)void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, slong prec)Sets res to F(z) (or \mathbf{F}(z)) computed with the linear fractional transformation selected by which: 1 for z/(z-1), 2 for 1/z, 3 for 1/(1-z), 4 for 1-z and 5 for 1-1/z.
void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec)Sets res to F(z) (or \mathbf{F}(z)) for z near the points \exp(\pm \pi i/3), where none of the transformations gives a convergent series, by analytic continuation along a path from a point where the direct series converges.
void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, slong prec)Given F(z_0) and F'(z_0) in f0 and f1, sets res0 and res1 to F(z_1) and F'(z_1), computed by integrating the hypergeometric differential equation along the straight segment from z_0 to z_1 with Taylor series and rigorous bounds. The points should be well isolated from the singular points 0 and 1. If F denotes the regularized function, f_0, f_1 must be values of the regularized function.
int acb_hypgeom_2f1_choose(const acb_t z)Chooses the method for computing {}_2F_1 from the location of z: returns 0 for direct summation, 1 to 5 for the transformation with that index in acb_hypgeom_2f1_transform, or 6 for the corner case.
Orthogonal polynomials and functions#
The algorithms for this section are described in Legendre functions and orthogonal polynomials.
void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, slong prec)void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, slong prec)Sets res to the Chebyshev polynomial or Chebyshev function of the first or second kind
void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, slong prec)Sets res to the Jacobi polynomial (or Jacobi function)
For nonnegative integer n this is a polynomial in a, b and z, also for parameters where the hypergeometric series is undefined; it is then evaluated by direct methods.
Sets res to the Gegenbauer polynomial (or Gegenbauer function)
For nonnegative integer n this is a polynomial in m and z, also where the hypergeometric series is undefined; it is then evaluated by direct methods.
Sets res to the Laguerre polynomial (or Laguerre function)
For nonnegative integer n this is a polynomial in m and z, also where the hypergeometric series is undefined; it is then evaluated by direct methods.
Morevoid acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, slong prec)Sets res to the Hermite polynomial (or Hermite function)
void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec)Sets res to the associated Legendre function of the first kind of degree n, order m and argument z; for m = 0 this is the Legendre polynomial P_n(z). Several branch cut conventions are in use. If type is 0, the function is
with cuts (-\infty, -1] and [1, \infty), and if type is 1, the function is
with the cut (-\infty, 1]. Type 0 and type 1 correspond to type 2 and type 3 in Mathematica and mpmath; other values of type raise an exception.
void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec)Sets res to the associated Legendre function of the second kind of degree n, order m and argument z; for m = 0 this is the Legendre function Q_n(z). If type is 0, the function is
and if type is 1,
Type 0 and type 1 correspond to type 2 and type 3 in Mathematica and mpmath; other values of type raise an exception.
For nonnegative integers n and m, sets res to (1-z^2)^{-m/2} P_n^m(z), which is a polynomial in z, computed with the three-term recurrence in the degree starting from P_m^m. The result is zero for m > n, and indeterminate if (n - m)/4 > \mathit{prec}, where the recurrence would lose all accuracy.
void acb_hypgeom_spherical_y(acb_t res, slong n, slong m, const acb_t theta, const acb_t phi, slong prec)Sets res to the spherical harmonic of degree n and order m at latitude angle \theta and longitude angle \phi, normalized so that
The definition is extended to negative m and n by symmetry. The function is a polynomial in \cos\theta and \sin\theta and is evaluated with acb_hypgeom_legendre_p_uiui_rec.
Dilogarithm#
The dilogarithm is \operatorname{Li}_2(z) = -\int_0^z \frac{\log(1-t)}{t} dt = z\, {}_3F_2(1,1,1;2,2;z), with the branch cut [1, +\infty) (the value on the cut is the limit from the lower half-plane). The algorithms are described in The dilogarithm.
void acb_hypgeom_dilog_bernoulli(acb_t res, const acb_t z, slong prec)Sets res to \operatorname{Li}_2(z) computed with the series expansion in w = \log(z), which converges like |w/(2\pi)|^n. This gives good convergence near z = e^{\pm i \pi / 3}, where the hypergeometric series fail. Since the coefficients involve Bernoulli numbers, the method is meant for moderate precision.
void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, slong prec)Sets res to \operatorname{Li}_2(z) computed with the hypergeometric series at 0, which is efficient only for |z| \ll 1.
void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, slong prec)Sets res to \operatorname{Li}_2(z) for z close to 0, using the Taylor series below 40000 bits (or for tiny |z|) and the bit-burst algorithm otherwise.
void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, slong prec)Sets res to \operatorname{Li}_2(z) computed by one of the transformations 1/z, 1-z, z/(z-1), 1/(1-z), selected by algorithm from 1 to 4, followed by acb_hypgeom_dilog_zero at the transformed argument. For algorithm between 5 and 7, it instead starts from the respective point \pm i, (1\pm i)/2 or 1 \pm i (with the sign of the imaginary part of z), where \operatorname{Li}_2 has a closed form in terms of \pi, \log 2 and Catalan's constant, and continues to z with the bit-burst method; these require that the imaginary part of z does not contain 0. The result is indeterminate if the transformation is not valid on the whole input ball.
void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, slong prec)Sets res to \operatorname{Li}_2(z) - \operatorname{Li}_2(a) computed with the Taylor expansion at a, summed by binary splitting. Both a and z should be well isolated from 0 and 1, except that a may be exactly 0. If the segment from a to z crosses the branch cut, the result is the analytic continuation along the segment rather than the principal branch.
void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, slong prec)Sets z0 to a point with a short binary expansion close to z and res to \operatorname{Li}_2(z) - \operatorname{Li}_2(z_0), computed with the bit-burst algorithm: z_0 is z truncated to 16 fractional bits, and continuation steps lead from it through the truncations of z to 32, 64, 128, ... bits to z. If z is close to the branch cut, it sets z0 to z and res to 0.
void acb_hypgeom_dilog(acb_t res, const acb_t z, slong prec)Sets res to the dilogarithm \operatorname{Li}_2(z) with an automatic choice of method: the series at 0 after the transformation that minimizes |z|, the Bernoulli series near e^{\pm i\pi/3} below 10000 bits, and expansions at the points of acb_hypgeom_dilog_transform otherwise.
Summation of hypergeometric series#
The functions in this section are the building blocks of the functions above. With
they compute partial sums of
There is no implicit k!: to compute the usual {}_pF_q, call the {}_pf_{q+1} functions with the extra lower parameter b_q = 1, or remove an upper parameter equal to 1 if there is one. The algorithms and the error bounds are described in Hypergeometric functions.
void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, ulong n)Sets C to a factor such that \left|\sum_{k=n}^{\infty} T(k)\right| \le C |T(n)|. The bound is infinite if p > q, if \operatorname{Re}(b_i + n) > 0 fails for some i, or if n is too small for the term ratio to be bounded below 1, even when the series converges. See Convergent series.
slong acb_hypgeom_pfq_choose_n(acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong prec)Heuristically chooses the number of terms n for summing the series at prec bits of working precision.
slong acb_hypgeom_pfq_series_choose_n(const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, slong len, slong prec)Like acb_hypgeom_pfq_choose_n for power series parameters and argument, using their constant terms; the result is at least len.
void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec)void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec)void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec)void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec)void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec)Sets s = \sum_{k=0}^{n-1} T(k) and t = T(n). Requires n \ge 0. The outputs must not alias the inputs. No truncation error is added.
Morevoid acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t w, slong n, slong prec)void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, const acb_t w, slong n, slong prec)Like acb_hypgeom_pfq_sum_bs and acb_hypgeom_pfq_sum, but given w = 1/z (and also z for the second function), which is advantageous when w has few bits, as in asymptotic expansions at an integer or short argument: binary splitting then divides by w instead of multiplying by the long z.
void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec)Sets res to
computed directly from the series with acb_hypgeom_pfq_sum and a rigorous bound for the truncation error \varepsilon from acb_hypgeom_pfq_bound_factor. If n < 0, the number of terms is chosen with acb_hypgeom_pfq_choose_n. If T(n) is exactly zero (a terminating series), no error is added. For real input the error is added to the real part only.
void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec)void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec)void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec)void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec)Sets s = \sum_{k=0}^{n-1} T(k) and t = T(n) for parameters and argument that are power series, with all arithmetic truncated to length len. Requires n \ge 0 and \mathit{len} \ge 1. The outputs must not alias the inputs.
void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec)Sets res to {}_pf_{q}(z) (regularized if regularized is set) for parameters and argument that are power series, truncated to length len \ge 1, summing n terms of the series and adding a rigorous bound for the truncation error in each coefficient (see Power series parameters). If n < 0, the number of terms is chosen automatically.
References#
- [DYF1999] A. Dzieciol, S. Yngve and P. O. Fröman, "Coulomb wave functions with complex values of the variable and the parameters", J. Math. Phys. 40, 6145 (1999), https://doi.org/10.1063/1.533083
- [Gas2018] D. Gaspard, "Connection formulas between Coulomb wave functions" (2018), https://arxiv.org/abs/1804.10976
- [Mic2007] N. Michel, "Precise Coulomb wave functions for a wide range of complex l, eta and z", Computer Physics Communications, Volume 176, Issue 3, (2007), 232-249, https://doi.org/10.1016/j.cpc.2006.10.004
- [NIST2012] National Institute of Standards and Technology, Digital Library of Mathematical Functions (2012), https://dlmf.nist.gov/
- [Fungrim] F. Johansson. Fungrim: the Mathematical Functions Grimoire. https://fungrim.org
The FLINT team, “acb_hypgeom.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/acb_hypgeom/index.html (generated 2026-10-20).
@misc{flint-doc-acb-hypgeom-index,
author = {{The FLINT team}},
title = {{acb\_hypgeom.h (module overview)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/acb_hypgeom/index.html},
note = {Generated 2026-10-20}
}