Bessel and incomplete gamma functions by steepest-descent integration
The convergent and asymptotic series of Bessel, Airy and Coulomb wave functions and Error functions, incomplete gamma functions and exponential integrals leave a gap: when the order and the argument are both large and of comparable size, the convergent series needs many terms and loses many digits to cancellation, and the asymptotic expansion does not reach the target precision. Both also behave poorly for wide input balls. FLINT fills the gap by integrating a contour integral representation numerically along a contour through the saddle points of the integrand, where the integrand does not oscillate. The cost is nearly independent of the parameters: a few hundred evaluations of the integrand at machine precision. The same contours give bounds for the functions and their derivatives that are tight in all parameter regimes.
The method has three layers: a contour is planned heuristically in double precision; bounds for the integral of the absolute value of the integrand along parts of the contour are computed rigorously; and the integral is evaluated by Gauss–Legendre quadrature with certified error bounds. Since the integrand is entire, correctness never depends on the quality of the contour, only the accuracy and the speed: everything computed in double precision (the contour, the quadrature rules, tolerances and working precisions) is a choice among valid alternatives, and every term of the error bound is computed in ball arithmetic for the choice made. For large parameters the quadrature can be replaced by a saddle-point expansion along the same contour (Saddle-point expansions).
Integral representations#
All the functions are integrals of with
between two ends: valleys at infinity where , or a finite starting point. Write . There are three kinds of valleys:
- : with near , where ;
- : with near (if );
- the linear valley: in a direction along which while stays bounded. This requires , or if .
Bessel functions. With , that is, , the Schläfli–Sommerfeld integrals [NIST2012, §10.9] read
with , and . The modified functions are
or with ; the rotation is chosen so that stays away from . The valleys are defined with , so that the formulas give the principal branches.
Incomplete gamma functions. In the variable , with , , , that is, ,
where is the linear valley, to the left. For this is the defining integral of ; otherwise it is the analytic continuation in .
Symmetries. For real and the two Hankel integrals are complex conjugates, so that and are the imaginary and real parts of a single integral (for ; for , is exponentially smaller than and is integrated directly). The reflection formulas for , and, at integers, , , are applied when . The integrals are analytic in the parameters, so for an input ball the computed enclosures hold for the analytic continuation from the midpoint; a ball which crosses the cut is split into its parts above and below it.
Planning the contour#
Saddles. With , is the quadratic equation , so the saddles form (at most) two families : for the Bessel functions, and for the incomplete gamma functions. Two saddles closer than the width of the cubic saddle into which they merge (the transition region ) are treated as one degenerate saddle with three descent directions. A finite starting point is a saddle with a single descent direction.
Descent paths. From each saddle the paths of steepest descent of are followed numerically, with steps that resolve the local scale of the integrand. A path ends in a valley, when the integrand has decreased by the target factor and the tail bound along a ray into the valley (Tails) is negligible, or in a lower saddle, when it passes within the width of that saddle: this is the situation on a Stokes line, where one saddle connects to another.
Routes. The saddles and the valleys are the nodes of a graph, and the descent paths its edges. Any path in the graph between the two ends is a valid contour (the integrand is entire and decays in the valleys), and its cost is the sum of the bounds of its edges. The cheapest route is found with the Bellman–Ford algorithm, tracing saddles lazily in order of increasing until the remaining ones cannot improve the route.
Ladders of saddles#
When , the Bessel-type problem has a linear valley in the vertical direction , . The valleys , , lead to it, separated by periodic copies of the same saddles, whose contributions decrease geometrically. When is large compared to , a contour between two valleys can be forced through the linear valley, and thus over infinitely many saddles.
Theorem 1 (Ladders). Let , with , and , so that . Then for or and every ,
Proof. Since , translating a contour from to by gives . The sum over is a geometric series, and the concatenated contours can be deformed into a single contour from into the linear valley: on the segments joining at to the line , , which tends to as for fixed .
If there is no direct route between two valleys and , each of them is connected to the linear valley, directly or by Theorem 1, and . This is the contour-integral form of connection formulas such as . For the incomplete gamma functions with large the contributions of the infinitely many saddles sum to ; the planner then looks for a route for the complementary function and uses , normally without cancellation, since the descent path from leads to the valley of the smaller of the two.
Where the landscape is flat (small parameters), the descent flow does not lead anywhere within the range of double precision, and classical contours are used instead: rays along the centres of the valleys joined by segments, or for a segment to the real axis followed by the axis. The convergent series work best there, so this is only a fallback.
Bounds#
Theorem 2. Let be any contour between the two ends, let , and let range over balls with midpoints and radii . Then for all parameters in the balls
provided the right-hand side converges.
Proof. is linear in the parameters, so . With this uniform majorant the integral converges uniformly on the balls, hence is analytic there and equal to the continuation of the function from the midpoint.
With this bounds the function itself. Since and , the weights and bound the derivatives with respect to the argument and the order. Along a path of steepest descent the integrand has constant phase, so for a contour through a single saddle the bound with equals the integral; the bounds are tight up to the cancellation between different saddles, that is, they bound the envelope of an oscillating function.
Panels. On a segment of the contour with midpoint and , Taylor's theorem gives for
and the integral of the exponential of a quadratic over is bounded in closed form.
Tails#
Beyond the last vertex of a polygon the contour continues along a ray: horizontally into , or into the linear valley. On a horizontal ray into , with , the exponent of Theorem 2 is at most , where is its value at , the rate at which decreases and collects the terms which can grow; the tail is then at most , an incomplete gamma function bounded in closed form. follows by the symmetry , , . Into the linear valley the exponent decreases at least linearly, and the tail is at most with that rate. The weights are carried along. The bound also verifies that the ray stays in the valley which the plan requires.
Arithmetic. While the contour is planned, the bounds are estimated in double precision; nothing depends on these estimates except the quality of the contour. Where a bound enters the radius of a result it is computed in ball arithmetic (sd_bound.c): and its derivatives are evaluated in acb arithmetic with the input balls themselves as parameters, which takes care of the suprema over the balls, of rounding, and of the cancellation between the terms of and the reference value. The polygon between two vertices can be replaced by the straight segment between them wherever the bound for the segment is not much larger, which leaves some 15 to 20 segments per contour.
Large parameters#
Doubles resolve the saddles and the values of for or so. Beyond, the widths of the saddles, , fall below the spacing of the doubles around them, and , whose terms are of the size of the parameters, cannot be evaluated to an absolute accuracy below 1. Everything above carries over if the points are taken relative to a base point close to the saddle: with ,
where , and . For the of interest the terms on the right are of the size of the left-hand side, so that it can be evaluated in double precision in without cancellation. A frame consists of an exact base point , of , , and computed in ball arithmetic and rounded, and of an exact reference value close to . Each saddle, and the starting point, has a frame; the planner works in double precision as before with the vertices as offsets in the frame of their saddle. The rigorous bounds are computed from at the exact points , with as many more bits as the parameters have beyond , and the quadrature evaluates the integrand in the frame, from balls for , , and computed once per frame. Its working precision is therefore that of small parameters, whatever the size of and ; the cost of an evaluation grows only weakly with the parameters. The midpoints of the parameters must be doubles: for the Bessel functions and for the incomplete gamma functions.
Quadrature#
Each piece of the contour is integrated as , where is at the saddle of the piece, rounded, so that along it; the pieces are combined in acb arithmetic and the tails are added to the radius.
Theorem 3. Let be analytic with on the closed disk , , and let . The error of the -point Gauss–Legendre rule for is at most
This is the second bound of Theorem 1 of Rigorous numerical integration, which acb_calc_integrate uses as well [Joh2018a], for the segment: the Bernstein ellipse with parameter of the segment is contained in the disk. (Trefethen [Tre2008] states the bound for the rule with points.) For , follows from the exact identity
(with ), so that for ,
with the derivatives evaluated on the input balls.
Chords. The rule is applied on chords joining vertices of the planned polygon. For each chord the number of nodes is minimized over , and a chord is extended over the following panels for as long as this lowers the number of nodes per panel. The rules, with nodes, are those of the cache of acb_calc_integrate. All of this is decided from double precision estimates; for the chord, and chosen, the bound is then computed rigorously and added to the radius. The outer parts of each polygon, where the integrand is below the tolerance, are bounded instead of integrated. For the incomplete gamma functions one more chord joins the double approximation of to the ball itself; the sum with a ball end point encloses the integrals over all chords from points of the ball.
Arithmetic. The nodes are evaluated in ball arithmetic with the input balls as parameters, so that the result encloses the function on the balls, and with the bits which cancels added to the working precision: up to about 200 bits in the vectorized multi-double ball arithmetic of dfloat, beyond (or where dfloat is not supported) in arb arithmetic, in parallel when several threads are available. A node where needs bits less for the same absolute error; this tapering saves about a third of the work at high precision. The radius of the result due to the input balls is about that of the weighted norms of Bounds, and the tolerance and working precision are relaxed accordingly, so that wide balls cost less than exact input.
Saddle-point expansions#
For large parameters the integrand is concentrated near each saddle, and the integral over the two descent paths of a simple saddle can be expanded there. This is the expansion of Debye type, with the coefficients generated numerically for the given parameters instead of as polynomials, so that no table is needed, complex parameters need no special treatment, and the error bound holds for the parameters at hand.
Let and . By the identity of Quadrature at ,
On the two descent paths with real, and is analytic near , with . The integral over the piece is
The coefficients follow from by comparing coefficients, operations for of them.
Theorem 4. For let
If , then is analytic with for , and .
Indeed, with for , so satisfies on , and by Rouché's theorem takes every value of modulus less than exactly once in ; , and the bound for is Cauchy's inequality.
Error bound. For , the difference between the integral over each descent path and terms consists of the truncation of the series on , bounded with the coefficient bounds of Theorem 4; the terms integrated beyond ; and the integral over the rest of the path, which is replaced (the integrand being entire) by a segment from an enclosure of to a vertex of the planned polygon followed by the rest of the polygon, bounded as in Bounds. The expansion reaches a precision of about bits, and needs fewer terms the larger is.
It is implemented for the Bessel kernel with exact parameters and contours made of pairs of descent paths through simple saddles, and replaces the quadrature where its estimated cost is lower, which is the case mainly at higher precision (2 to 8 times faster at 333 bits for ).
Choice of method#
acb_hypgeom_bessel_j, acb_hypgeom_bessel_y, acb_hypgeom_bessel_i, acb_hypgeom_bessel_k (and the scaled versions), acb_hypgeom_gamma_upper and acb_hypgeom_gamma_lower choose between the convergent series, the asymptotic expansion and the integration by the same scheme. For each method the number of guard bits it needs and its cost are estimated in double precision, and the cheapest is tried first at the precision raised by its guard bits. Each result is a rigorous enclosure, so the estimates only affect the running time: the best result is kept, and the first which is accurate enough is returned.
Guard bits. With exact input, a method which loses bits to cancellation gives full accuracy when evaluated with more bits.
- A convergent series loses the size of its largest term relative to the function. The largest term follows from the ratios of the terms, and the size of the function from the leading-order (Debye) approximations, beyond the turning point and in the oscillatory region, with , and similarly for the other functions. For small orders this is the classical bits for and ; for the alternating series for loses twice the growth of its terms, whereas the series for loses nothing. For and with complex orders the sizes are with in the sector where this holds DLMF, 10.41(iv).
- The asymptotic expansions of the Bessel functions have terms which grow before they decrease when is not small compared to ; the growth is lost to cancellation, and the expansion is used only where its smallest term, times the factor by which the error bound exceeds it, reaches the precision. For a half-integer order the expansions terminate and are exact, and are used for any where they are cheapest.
- For the incomplete gamma functions, the series loses nothing for and about bits otherwise, less where the end point dominates the integral; the upper function as loses bits more. For a positive integer the expansion of terminates, , and loses nothing for . For the closed forms are returned at once.
Costs. The numbers of terms follow from the same ratios, and the cost per term from timings; with exact short and the series are summed by binary splitting, which costs less. The cost of the integration is modelled per descent path as a function of the precision only (the saddle-point expansion where that is cheaper). These are costs with the quadrature nodes at hand: the nodes are computed on the first call at each precision (about a second at 3333 bits) and cached, and a tenth of this is added to the cost of the quadrature, so that the series are preferred for a single evaluation and the integration where it is much faster.
Order of the attempts. In the easiest cases the estimates cost as much as the function, and a first attempt with a few guard bits comes before them (small , or large for and the upper incomplete gamma function). Otherwise the cheapest method comes first, and a result which falls short by a known number of bits is repeated with that many more; else the precision is doubled. The integration is tried before any attempt which is estimated to cost more. On surveys of exact inputs with and up to 30 times the precision, from 333 to 30000 bits, the automatic functions take a median of about the time of the best single method run with exactly the guard bits it needs, and at most about four times.
Inexact input. A result within a few bits of the accuracy which the input allows is accepted (that accuracy is estimated from condition numbers). For input which is as accurate as the precision, up to 1000 bits, a few more bits may be missing in a first result on the input balls, since the alternatives cost several times as much there and the caller can raise the precision. A ball which meets a branch cut from both sides is left to the series, since no method gives more than the jump of the function. Otherwise the routes are, in order of cost:
- A first result which is already tight. Close to a zero of the function the accuracy which the input allows is lower than its estimate. A first result on the balls is final if its radius is within three bits of or , the image of the input to first order, computed from one more value at low precision.
Only inexact. The function is evaluated at the midpoint of , and is added. For the incomplete gamma functions is evaluated on the ball. A Bessel function satisfies (with , for and , and the analogues for , and the scaled functions), so that satisfies with , and along the segment from to any point of the ball
where costs one more value at low precision (for and at integer orders, from or and the Wronskians). With the bound is within a small factor of unless the ball is very wide.
- Monotone functions. For real arguments where the function is monotone in each inexact variable, the range over the input box is the interval between the values at two corners, the optimal enclosure, at the cost of two evaluations with exact input. This holds for , , , and the incomplete gamma functions with , including and (for ), for which it also avoids the dependency between and . It is used for input with at most 64 accurate bits; narrower balls at high precision are better served by the next route.
An inexact order. The functions are entire in the order, so with a bound for on the disk , Cauchy's estimates give
With the bound is up to terms of higher order, so that a crude is enough: the bounds of the integral representations, such as , carried to orders with a negative real part by the recurrences. The second value needs fewer bits than the first.
- Otherwise the integration, which works with the input balls directly, or the evaluation at the midpoints with the derivative bounds of Bounds, whichever is estimated to cost less; both give about the same radius.
The integration applies for ( for the incomplete gamma functions). Its accuracy is limited only by cancellation between the contributions of different saddles, which is inherent in the function ( near a zero) or occurs for and with close to a negative integer.
Use in FLINT#
- Evaluation:
acb_hypgeom_bessel_j_integration,acb_hypgeom_bessel_y_integration,acb_hypgeom_bessel_jy_integration,acb_hypgeom_bessel_h1_integration,acb_hypgeom_bessel_h2_integration,acb_hypgeom_bessel_i_integration,acb_hypgeom_bessel_k_integration; these are called by the automatic functionsacb_hypgeom_bessel_j,acb_hypgeom_bessel_y,acb_hypgeom_bessel_jy,acb_hypgeom_bessel_i,acb_hypgeom_bessel_k,acb_hypgeom_gamma_upper,acb_hypgeom_gamma_lowerand their real wrappers inarb_hypgeom. - The versions restricted to series and asymptotic expansions:
acb_hypgeom_bessel_j_nointegrationand the like,acb_hypgeom_gamma_upper_nointegration,acb_hypgeom_gamma_lower_nointegration. - The profile program
src/acb_hypgeom/profile/p-catalog.ccompares the automatic functions with the integrals and with the versions without them on a catalog of inputs; see Profiling. - The implementation is in
src/acb_hypgeom/sd_plan.c(contours and estimates, in double precision, and the frames for large parameters),sd_bound.c(the rigorous bounds),sd_integrate.c(quadrature),sd_expand.c(saddle-point expansions),bessel_integration.candgamma_incomplete_integration.c(the two families), with the dispatchers inbessel.candgamma_incomplete.c.
Referenced from#
acb_hypgeom_gamma_upper_asymp,acb_hypgeom_gamma_upper_1f1a,acb_hypgeom_gamma_upper_1f1b,acb_hypgeom_gamma_upper_singular,acb_hypgeom_gamma_upper_nointegration,acb_hypgeom_gamma_upper- acb_hypgeom.h (module)
acb_hypgeom_bessel_j_nointegration,acb_hypgeom_bessel_jacb_hypgeom_bessel_j_integration,acb_hypgeom_bessel_y_integration,acb_hypgeom_bessel_jy_integration,acb_hypgeom_bessel_h1_integration,acb_hypgeom_bessel_h2_integration,acb_hypgeom_bessel_i_integration,acb_hypgeom_bessel_k_integration- Bessel, Airy and Coulomb wave functions (algorithm)
- Error functions, incomplete gamma functions and exponential integrals (algorithm)
- Hypergeometric functions (algorithm)
References#
- [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
- [Tre2008] L. N. Trefethen, "Is Gauss Quadrature Better than Clenshaw-Curtis?", SIAM Review, 50:1 (2008), 67-87, https://doi.org/10.1137/060659831
The FLINT team, “Bessel and incomplete gamma functions by steepest-descent integration,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/steepest-descent.html (generated 2026-11-25).
@misc{flint-doc-algorithms-special-functions-steepest-descent,
author = {{The FLINT team}},
title = {{Bessel and incomplete gamma functions by steepest-descent integration}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/steepest-descent.html},
note = {Generated 2026-11-25}
}