Legendre functions and orthogonal polynomials
The Legendre polynomials , and more generally the classical orthogonal polynomials (Jacobi, Gegenbauer, Chebyshev, Laguerre, Hermite), are terminating hypergeometric series, for example
For integer degree they can be evaluated directly as polynomials, but for large this is slow and numerically unstable: the coefficients grow exponentially while on . FLINT has a dedicated algorithm for with real and word-size , which also gives the nodes and weights of Gauss–Legendre quadrature; the other functions use the general and code with a few direct methods for integer degrees.
Legendre polynomials#
The algorithm of arb_hypgeom_legendre_p_ui is that of Johansson and Mezzarobba [JM2018]. It computes and together for real , and by only is needed. Four expansions are available.
Expansion at (
arb_hypgeom_legendre_p_ui_one):The terms decrease quickly when is small, and the series can be truncated after terms with a bound for the remainder.
Expansion at (
arb_hypgeom_legendre_p_ui_zero): for even ,and an analogous formula with for odd . The terms decrease when is small.
Asymptotic expansion (
arb_hypgeom_legendre_p_ui_asymp): with , , the Stieltjes seriessummed as the real part of a complex series in , with the explicit bound , , which follows from the analysis of Bogaert, Michiels and Fostier [Bog2012]. The number of terms needed decreases as grows; for much larger than the precision a handful of terms suffice, independently of .
- Recurrence (
arb_hypgeom_legendre_p_ui_rec): the three-term recurrence , evaluated in fixed-point arithmetic with machine words and a rigorous bound for the accumulated rounding error. It is stable on , costs cheap operations, and is the fastest method for moderate and precision.
arb_hypgeom_legendre_p_ui selects the method from estimates of the cost of each expansion: the number of terms, the precision lost to cancellation in the series at 0 and at 1 (whose terms can be much larger than ), and the size of the error term of the asymptotic expansion. The recurrence is used for below a few hundred at low precision, unless is very close to 0 or 1; for only the expansion at 1 is used (with an early stop if it converges quickly). The working precision is raised by the estimated cancellation, and for inexact the function evaluates at the midpoint and adds the error propagated from the radius , bounded by and on the ball (arb_hypgeom_legendre_p_ui_deriv_bound, which uses and for , with ).
Gauss–Legendre nodes and weights#
The roots of and the weights are computed by arb_hypgeom_legendre_p_ui_root: an initial approximation with an explicit error bound due to Petras [Pet1999], Newton iteration with a priori error bounds at low precision, and interval Newton iteration at doubling precisions above; each step evaluates and with the method above, and the doubling of the precision means that the final evaluation dominates the cost. This is what makes high-degree Gauss–Legendre quadrature in acb_calc_integrate practical at high precision [JM2018]. See Roots of Legendre polynomials and Gauss–Legendre nodes.
Legendre functions#
For complex degree , order and argument , the associated Legendre function of the first kind is
with the regularized (type 0 has cuts on and , type 1 on ), and the function of the second kind is
(and analogously for type 1). acb_hypgeom_legendre_p evaluates the representation with acb_hypgeom_2f1, which handles the transformations needed for large . For integers it uses instead the recurrence of acb_hypgeom_legendre_p_uiui_rec for , starting from and , when the precision is low compared to , is small, or is near 1 (where the transformations are singular); real with goes to arb_hypgeom_legendre_p_ui. If the recurrence would lose all accuracy and the result is indeterminate.
For integer , the defining formula for is a limit, so acb_hypgeom_legendre_q uses connection formulas without the removable singularity. For type 0 it evaluates two ordinary series in with gamma and trigonometric prefactors [WQ3a]. For type 1 it evaluates one regularized in [WQ3b] when the ball is away from the real half-line and from the square (the formula is invalid on ), and otherwise combines the type 0 function and [WQ3c]. (The formula [WQ3d] would also be convenient, but it is incorrect in the lower half-plane.)
The spherical harmonics
are polynomials in and , which acb_hypgeom_spherical_y evaluates with acb_hypgeom_legendre_p_uiui_rec.
Other orthogonal polynomials#
The other classical families are defined for complex degree through or :
| Function | Definition | Direct method for integer |
|---|---|---|
| Chebyshev , | , | acb_chebyshev_t_ui, acb_chebyshev_u_ui (word-size ) |
| Jacobi | explicit double sum for and | |
| Gegenbauer | recurrence in for and | |
| Laguerre | recurrence in for and | |
| Hermite | — |
The direct methods cover the cases where the hypergeometric representation is singular although the polynomial is defined (the lower parameter , or is near a nonpositive integer). For non-integer degree, the Chebyshev functions use and (with for outside ) away from , and the series near it.
Use in FLINT#
arb_hypgeom_legendre_p_uiand its methodsarb_hypgeom_legendre_p_ui_zero,arb_hypgeom_legendre_p_ui_one,arb_hypgeom_legendre_p_ui_asymp,arb_hypgeom_legendre_p_ui_rec;arb_hypgeom_legendre_p_ui_rootfor quadrature, used byacb_calc_integrateandarb_fpwrap.acb_hypgeom_legendre_p,acb_hypgeom_legendre_q,acb_hypgeom_legendre_p_uiui_rec,acb_hypgeom_spherical_yand the real versions.acb_hypgeom_chebyshev_t,acb_hypgeom_chebyshev_u,acb_hypgeom_jacobi_p,acb_hypgeom_gegenbauer_c,acb_hypgeom_laguerre_l,acb_hypgeom_hermite_hand the real versions.
Referenced from#
References#
- [JM2018] F. Johansson and M. Mezzarobba, "Fast and rigorous arbitrary-precision computation of Gauss-Legendre quadrature nodes and weights", preprint (2018), https://arxiv.org/abs/1802.03948
- [Bog2012] I. Bogaert, B. Michiels and J. Fostier, "O(1) computation of Legendre polynomials and Gauss-Legendre nodes and weights for parallel computing", SIAM Journal on Scientific Computing 34:3 (2012), C83-C101
- [Pet1999] K. Petras, "On the computation of the Gauss-Legendre quadrature formula with a given precision", Journal of Computational and Applied Mathematics 112 (1999), 253-267
- [WQ3a] The Wolfram Functions Site, formula 07.11.26.0033.01. http://functions.wolfram.com/07.11.26.0033.01
- [WQ3b] The Wolfram Functions Site, formula 07.12.27.0014.01. http://functions.wolfram.com/07.12.27.0014.01
- [WQ3c] The Wolfram Functions Site, formula 07.12.26.0003.01. http://functions.wolfram.com/07.12.26.0003.01
- [WQ3d] The Wolfram Functions Site, formula 07.12.26.0088.01. http://functions.wolfram.com/07.12.26.0088.01
The FLINT team, “Legendre functions and orthogonal polynomials,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/legendre.html (generated 2026-11-02).
@misc{flint-doc-algorithms-special-functions-legendre,
author = {{The FLINT team}},
title = {{Legendre functions and orthogonal polynomials}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/legendre.html},
note = {Generated 2026-11-02}
}