Skip to content

Answer ln(x) times Ei or Shi over [0, 1]: Gruntz first through a logarithmic singularity, and the sine integrals as series - #2705

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
fix-2694-log-times-shi-and-ei-integrals
Dec 4, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
fix-2694-log-times-shi-and-ei-integrals

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #2694

Cause

Two separate causes, each confirmed by ablating it on the fixed build.

ln(x) Ei(x). ThroughALogarithmicSingularity rewrites Ei(x) as eulergamma + ln(x) at 0. That leaves
ln(x) (x (gamma + ln x) - e^x) - (x (gamma + ln x) - e^x - gamma - ln x), an infinity less an infinity, and the
rewrite handed it back to the general limit machinery. Without a budget that machinery answers it in about 0.1–0.5 s,
because the descent asks a quotient in it whole (AsTheWholeLimit). A definite integral takes its bound's limit under
a budget of limits, though, and under any budget AsTheWholeLimit declines. The search then goes to l'Hopital's rule,
which keeps simplifying derivatives. Measured on master: LimitAtTheBound without the budget took 116 ms; with the
budget it did not return in 20 s, at 2000 and at 10^9 alike. So the budget running out is not the cause; the refusal
is. Letting AsTheWholeLimit answer under the budget, with nothing else changed, answers the integral in 1.0 s.

ln(x) Shi(x). The Chi(x) gets the same rewrite, but x Shi(x) ln(x) remains, and Gruntz's algorithm had no
series for Shi. With the Gruntz-first change and without the Shi series, this integral still does not return in
20 s.

Change

  • ThroughALogarithmicSingularity asks Gruntz's algorithm first for what it leaves. A finite one-sided destination is
    moved out to +oo. If the algorithm declines or answers NaN, the existing ComputeLimit runs as before.
  • Gruntz's algorithm now expands Si and Shi as their Taylor series where the argument settles at a finite real
    value. That covers mrv, AnalyticWhereItsArgumentEndsUp and AsymptoticSeries.Expand. Through takes an optional
    derivativeAtZero, because Si'(t) = sin(t)/t and Shi'(t) = sinh(t)/t have no value at 0 to substitute. The
    k-th derivatives at 0 are 0 for even k; for odd k = 2j + 1 they are (-1)^j / k for Si and 1 / k for Shi.

Measurements

Measured on the 70-row family int_0^1 ln(x)^p F(a x) and x ln(x) F(x), with F in {Shi, Chi, Ei, Si, Ci, erf,
erfi, sinh, cosh - 1, e^x - 1}, p = 1, 2, a = 1, 2, 1/2, k = 0, 1. Each row ran through Simplify with a 20 s timeout,
and every answer was evaluated to 45 digits and compared with mpmath's quadrature (runfam.py). Master is 280ff1526.

master branch
right 28 36
declined 38 34
timeout 4 0
WRONG 0 0

No row that master answered changed its verdict. The new answers are below. Each agrees with mpmath's tanh-sinh
quadrature to better than 1e-50 at 50 digits.

integrand over [0, 1] master branch value
ln(x) Shi(x) timeout Chi(1) - Shi(1) - 1 + (e + 1/e)/2 - eulergamma -0.2535189644818093558057702447854623975
ln(x) Ei(x) timeout e - 1 - eulergamma 1.141066163557512374753775381270260067
ln(x) Shi(2x) declined -1/2 (1 - Chi(2) + 2 Shi(2) + ln(2) - (e^-2 + e^2)/2 + eulergamma) -0.5293175492204417357510715258612124060
ln(x) Shi(x/2) declined Ei(-1/2) + Ei(1/2) - 2 - (Shi(1/2) - (e^-1/2 + sqrt(e))) - 2 (ln(1/2) + eulergamma) -0.1254354780030679595860416170843343710
ln(x) Chi(2x) timeout Shi(2)/2 - Chi(2) - 1/(4 e^2) + e^2/4 0.6115469979540826826646605852649091753
ln(x) Chi(x/2) timeout 2 Shi(1/2) - Chi(1/2) + sqrt(e) - e^-1/2 2.108960955583322730825307068127012154
ln(x) Si(2x) declined (1 - (Ci(2) + cos(2) + 2 Si(2)) + ln(2) + eulergamma)/2 -0.4736485501858170679153465042770462935
ln(x) Si(x/2) declined 2 - 2 (Ci(1/2) + Si(1/2)/2 + cos(1/2)) + 2 (ln(1/2) + eulergamma) -0.1245674155274112163440093933908340755
ln(x) Shi(sqrt(x)) (outside the family) timeout Ei(-1) - Ei(1) - Shi(1) + e -0.4534707976681403083552395933349713793

Several rows that were already right now come back much faster, because the logarithmic singularity reaches Gruntz
directly. ln(x) erf(x) went from 5.7 s to 0.6 s, ln(x) erfi(x/2) from 7.9 s to 0.65 s, and ln(x) Chi(x) from
5.0 s to 0.54 s. Two declines looked slower in the parallel family run: ln(x)^2 Chi(x) went from 3.1 s to 4.0 s, and ln(x)^2 Shi(2x) from 3.3 s to 3.9 s. Re-measured alone, alternating, 3 runs each: 3.02/3.06/3.05 s on master against 3.02/2.99/3.45 s on the branch, and 3.44/3.60/3.23 s against 3.79/3.24/3.47 s. That is within noise.

New limits: ln(x) Shi(x) at 0+ is 0, ln(x) (x Shi(x) - cosh(x)) + ln(x) at 0+ is 0, and
x^3 (Shi(1/x) - 1/x) at +oo is 1/18. Master left all three unevaluated.

Suites and harnesses (branch 836513f86 against master 280ff1526, alternating under the chain lock)

  • C# unit tests: 22320 passed, 0 failed, 13 skipped (8 m 15 s). F# wrapper: 135 passed.
  • CasBench: 120/121 on both, 0 wrong, 0 error, 0 timeout. Verdicts and answers are identical; the summed row time
    is 1712 ms on master and 1721 ms on the branch.
  • limitcheck (600 expressions): identical reports; 28.2 s on master, 28.8 s on the branch.
  • symlimitcheck (190 cases): identical reports; 25.0 s on master, 25.1 s on the branch.
  • ImproperIntegralTest, each row alone, 3 runs each:
    • ln(x) erfc(x): 3 s on master, 0.61 s on the branch.
    • ln(x) erfi(x): 4 s on master, 0.59 s on the branch.
    • ln(x) arccos(x): 5 s on both.
    • 1/(t^2+y^2): 0.52 s on both.
    • t^2 e^(-(t-y)^2): 0.28 s on both.
  • The ln(x) Si(2x) row of ABoundWhoseLimitIsNotDecidedLeavesTheIntegralAsWritten is now answered, so it moved to the
    new Issue2694_... theory. A row of the same kind (antiderivative found, limit undecided, quick) was looked for:
    ln(x) arsinh(x) and ln(x) arcsin(x) take more than 20 s, and the others found have no antiderivative. So
    ln(x) arccos(x) is left alone.

🤖 Generated with Claude Code

…rithmic singularity, and the sine integrals as series

Where ThroughALogarithmicSingularity reads Ei, Ci, Chi or li as eulergamma plus a logarithm, what is left
is an infinity less an infinity of logarithms, which is what Gruntz's algorithm settles; it is now asked
first, with the rest of the machinery behind it. Under the budget a definite integral's bound is taken
within, the descent refuses to ask a quotient whole, and l'Hopital's rule searched the antiderivative of
ln(x) Ei(x) at 0 for longer than twenty seconds at any size of budget. Gruntz's algorithm also expands
Si and Shi as their series where the argument settles, with the derivatives at 0 given, since sin(t)/t
and sinh(t)/t have no value there.

#2694

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.11 milestone Dec 4, 2026
@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.65%. Comparing base (280ff15) to head (836513f).

Files with missing lines Patch % Lines
...tions/Continuous/Limits/Gruntz/AsymptoticSeries.cs 50.00% 0 Missing and 4 partials ⚠️
...ns/Continuous/Limits/Solvers/Solvers.Definition.cs 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2705   +/-   ##
=======================================
  Coverage   86.65%   86.65%           
=======================================
  Files         346      346           
  Lines       76936    76959   +23     
  Branches    22633    22644   +11     
=======================================
+ Hits        66669    66692   +23     
+ Misses       5535     5534    -1     
- Partials     4732     4733    +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.14% <77.77%> (+<0.01%) ⬆️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...iMath/Functions/Continuous/Limits/Gruntz/Gruntz.cs 78.51% <100.00%> (+0.16%) ⬆️
...ns/Continuous/Limits/Solvers/Solvers.Definition.cs 88.77% <87.50%> (-0.09%) ⬇️
...tions/Continuous/Limits/Gruntz/AsymptoticSeries.cs 82.07% <50.00%> (-0.45%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit 409d688 into master Dec 4, 2026
41 of 44 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Dec 4, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the fix-2694-log-times-shi-and-ei-integrals branch December 4, 2026 21:07
This was referenced Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

integral(ln(x) Shi(x), x, 0, 1) and integral(ln(x) Ei(x), x, 0, 1) do not return in 20 s

1 participant