Repository navigation
Add generalized Laguerre polynomials for real alpha - #1632
Merged
Merged
Conversation
laguerre(n, alpha, x) with real alpha no longer truncates alpha. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
laguerre(n, alpha, x)with a floating-point alpha evaluates the generalized Laguerre polynomial L_n^α(x) instead of truncating alpha to an integer; associated polynomials now also use the compensated recurrence.Requested in #1128 (now on the #303 wishlist). Gauss–Laguerre quadrature and
laguerre_zeros(n, alpha)for real α landed in #1517 and #1609; evaluating L_n^α itself was the missing piece. On develop,laguerre(3, 0.5, 1.2)silently converts 0.5 to the unsigned order 0 and returns L_3(1.2) = −0.728 instead of L_3^{1/2}(1.2) = −0.8305.API.
laguerre(n, alpha, x)andlaguerre(n, alpha, x, pol)take any real α when its type is floating point (L_n^α is a polynomial in α, so no domain restriction). A non-negative integer order still selects the associated polynomial and leaves the result type toxalone, solaguerre(n, 2, 1.0f)is stillfloat; a floating α promotes withx. A negativeintorder is now treated as the real α it is (on develop it wrapped to about 4·10⁹).Source compatibility. Calls that passed a fractional floating-point order, like
laguerre(n, 2.7, x), used to compute L_n^2 and now compute L_n^2.7, without a diagnostic. An integer-valued floating order gives the same value as before, butlaguerre(n, 2.0, 1.5f)now returnsdoubleinstead offloat.Method. The compensated three-term recurrence that
laguerre_zerosalready uses (laguerre_family::compensated_value, from #1609): the rounding error of each step, and of its coefficients 2c + 1 + α and c + α, is carried forward by the same recurrence, as plainlaguerre(n, x)does. The associated polynomials with integer m used the plain recurrence and now go through it too.Accuracy (against 600-bit sums Σ (−1)^k C(n+α, n−k) x^k/k! at the double arguments): correctly rounded in
doubleon every plotted point; the 18 test references (n up to 500, α from −1.5 to 1000) are within 4 ε in float and double, and incpp_bin_float_50to the references' precision.laguerre(50, 3, x), developlaguerre(50, 3, x), this PRlaguerre(50, 0.5, x)laguerre(30, -0.7, x)laguerre(200, 12.25, x)Performance (google/benchmark, Apple M1 Pro, -O2,
reporting/performance/laguerre_performance.cpp, x = 3.5):laguerre(n, x)(unchanged)laguerre(n, 3, x), developlaguerre(n, 3, x), this PRlaguerre(n, 0.5, x)The associated polynomials now cost what the plain ones already did (2.2–8× more than before) in exchange for being correctly rounded instead of tens of ulps off.
🤖 Generated with Claude Code