Repository navigation
Sum the incomplete gamma function's lower series as DLMF 8.7.3 in the left half-plane - #2088
Merged
Rafael-SOWNet merged 1 commit intoOct 23, 2026
Conversation
… left half-plane Gamma(a) - gamma(a, z) summed gamma(a, z) as z^a e^(-z) sum_k z^k/(a)_(k + 1) (DLMF 8.7.1) everywhere. On the negative axis its terms alternate, are e^|z| in size and sum to e^(-|z|), so twice |z|/ln 10 guard digits were carried, and at that precision Gamma(a) was computed afresh: Gamma(1/3, -143) took 9.6 s, Gamma(1/2, -100 + 5i) 5.6 s, Gamma(-5/2, -60) 2.4 s. In the left half-plane it is now z^a sum_k (-z)^k/(k! (a + k)) (DLMF 8.7.3), as E_1 already was, whose terms are of one sign on that axis and which loses (|z| + Re z)/ln 10 digits: 6 ms, 9 ms and 6 ms. The large guard had been hiding two defects on the cut, where each part of the value should be accurate to its own size: - z^a was e^(a ln|z| + i a pi) with a pi rounded, so cos(pi/2) was 10^(-W) where it is 0. Times e^143, that was the real part of Gamma(1/2, -143), which is sqrt(pi). The angle is reduced exactly before pi multiplies it, and is exactly 0 at a half-whole a. - Past (P + 5) ln 10 the continued fraction, whose coefficients are real there, gives e^(i pi a) times a real function, the mean of the two sides. It falls short of the value from above by -i e^(i pi a) sin(pi a) Gamma(a). That is below the precision of the modulus, but it is the whole of the real part at a half-whole a and of the imaginary part at a = -n. On master Gamma(1/2, -300)'s real part was 3e13 times sqrt(pi), Gamma(11/2, -300)'s 1.6e25 times Gamma(11/2), and Gamma(-3, -300)'s imaginary part 9e4 times pi/6. Checked part by part against mpmath at 300-400 digits on 320 points: 16 orders, half-whole, whole, complex and odd-denominator ones among them, at 20 points of the left half-plane including both sides of the threshold. Every part agrees to 1e-97 of its own size. On master, 18 of the 80 cases past the threshold had a part wrong, by up to 1e113 times its size. The grid took 48.4 s on master and 3.4 s here. Part of #2075. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This was referenced Oct 23, 2026
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.
Evaluates
gamma(a, z)in the left half-plane by a series whose terms do not cancel there, and makes each part of the value on the cut accurate to its own size. Part of #2075.Speed.
gamma(a, z)wasGamma(a)less the lower function, summed everywhere asz^a e^(-z) sum_k z^k/(a)_(k + 1)(DLMF 8.7.1). On the negative axis its terms alternate, aree^|z|in size and sum toe^(-|z|). So twice|z|/ln 10guard digits were carried, andGamma(a)was computed afresh at that precision. In the left half-plane the lower function is nowz^a sum_k (-z)^k/(k! (a + k))(DLMF 8.7.3), asE_1already was. Its terms share a sign on that axis, and it loses(|z| + Re z)/ln 10digits.gamma(1/3, -143)gamma(1/2, -100 + 5i)gamma(-5/2, -60)gamma(1/3, -30)The first is the evaluation that made #2087 change a test's sign,
e^(c (d + f x)^3)toe^(-c (d + f x)^3), to keep it under a second.Two defects on the cut, which the guard digits had hidden. Each part of the value should be accurate to its own size, and on the negative axis one part is often exactly
Gamma(a)or a multiple ofpi.z^awase^(a ln|z| + i a pi)witha pirounded, socos(pi/2)came out as10^(-W)where it is 0. Times the lower function'se^143, that was the real part ofgamma(1/2, -143), which issqrt(pi). The angle is now reduced exactly beforepimultiplies it, and the cosine is exactly 0 at a half-wholea.|z| = (P + 5) ln 10the continued fraction is used, and on the cut its coefficients are real. It converges toe^(i pi a)times a real function, the mean of the two sides, and falls short of the value from above by-i e^(i pi a) sin(pi a) Gamma(a). That is below the precision of the modulus, but it is the whole of the real part at a half-wholea, and of the imaginary part ata = -n, where it is-i (-1)^n pi/n!. On master the real part ofgamma(1/2, -500)was2.9e100, where it issqrt(pi).Checked part by part against mpmath at 300 to 500 digits. The grid is 16 orders (half-whole, whole, complex and odd-denominator ones among them) at 20 points of the left half-plane, on both sides of the threshold:
The worst part on either side is
gamma(7/3, -5 - 2i)'s, and comes from7/3itself being rounded to 100 digits.Measured on Rubi's suite, with the harness that reads
GAMMA, against this branch's base3dbae246, the whole corpus each side:3dbae246All five gains were timeouts of the harness's own check. After the library answers, it evaluates the answer again at 300 and 2000 digits, and for
6.1.1:205-207and6.1.3:98/100that putgamma(a, z)in the left half-plane. They now finish in 0.08 to 1.9 s. The time per stream is 1.006, 1.005 and 0.922 of the base's. Two rows' allocation grew in the run,6.1.7:196and8.1:302, and alone they are the same on both builds: 1.079 GB each, and 1.406 against 1.408 GB.Eight tests added: three far into the left half-plane, four past the threshold on the cut, and
gamma(1/3, -143)with the real root. The suite passes (16,947), and so do the MCP tests (329).🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura