Skip to content

Do not take an exponential of the variable out of the linears recurrence as a constant - #2741

Open
Rafael-SOWNet wants to merge 1 commit into
masterfrom
fix-2717-exp-arsinh-sqrt-integral-zero
Open

Rafael-SOWNet wants to merge 1 commit into
masterfrom
fix-2717-exp-arsinh-sqrt-integral-zero

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

The recurrence for a negative whole power of a linear beside a power of another (SolveANegativePowerOfALinearBesideAPowerOfAnotherByTheRecurrence) moved every factor with a constant base into its constant before it looked at the exponent. So e^x, 2^x and e^(-1/x) were taken out of the integral, and e^x/(x^2 sqrt(1 + x)) was answered as e^x times the antiderivative of 1/(x^2 sqrt(1 + x)).

How #2717 reaches it. By parts, then the substitution u = 1/sqrt(x) and w = u^2, the remainder of e^(-x) arsinh(sqrt(x)) reaches e^(-1/w) (1 + w)^(-1/2)/w^2. The wrong answer for that made the whole antiderivative a constant: its derivative is 0, so the definite integral was 0 on every interval. Traced at the dispatcher. The fix reads the exponent first, so a factor with the variable in its exponent declines the rule, as a variable base already did. These integrals are not elementary: the remainder ∫ e^(-x)/(2 sqrt(x) sqrt(x + 1)) is an incomplete Bessel-type integral. So they are left unevaluated.

Variants against mpmath quad (dps 30), simplify(integral(f, x, a, b)), master 409d68805 against this branch:

f [a, b] true master branch
exp(-x)*arsinh(sqrt(x)) [0, 1] 0.3526065851 0 unevaluated (35 s)
exp(-x)*arsinh(sqrt(x)) [1, 2] 0.2335110726 0 > 20 s
exp(-x)*arsinh(sqrt(x)) [0, +oo] 0.7620546929 0 > 20 s
exp(x)*arsinh(sqrt(x)) [0, 1] 1.1491367447 0 > 20 s
exp(-2*x)*arsinh(sqrt(x)) [0, 1] 0.2172480749 0 > 20 s
exp(3*x)*arsinh(sqrt(x)) [0, 1/2] 0.5926112301 0 > 20 s
exp(-x)*arsinh(sqrt(2*x)) [0, 1] 0.4729690043 0 > 20 s
exp(-x)*arsinh(sqrt(x/3)) [1, 2] 0.1485401416 0 > 20 s
exp(-x)*arcosh(sqrt(x+1)) [0, 1] 0.3526065851 0 unevaluated
exp(-x)*ln(sqrt(x+1)+sqrt(x)) [1, 2] 0.2335110726 0 unevaluated
exp(-x)*ln(sqrt(x+2)+sqrt(x)) [0, 1] 0.4766731656 0.2190762916 unevaluated
exp(-x)*ln(sqrt(x+3)+sqrt(x)) [1, 2] 0.2762780763 0.1277379348 unevaluated
exp(-x)*ln(sqrt(x+1/2)+sqrt(x)) [0, +oo] 0.6430933340 > 20 s unevaluated
exp(x)/(x^2*sqrt(1+x)) [1, 2] 1.3326495260 -0.0851631790 unevaluated
2^x/((x+1)^3*sqrt(x+2)) [0, 1] 0.3129531029 0.1857837808 unevaluated
exp(-1/x)/(x^2*sqrt(1+x)) [1, 2] 0.1539907834 0.0701375839 unevaluated
exp(x)*x/((x+1)^2*sqrt(x)) [1, 2] 0.8922443860 2.7998609927 unevaluated
exp(-x)/(x^2*sqrt(x+1)) [1, 3] 0.0939757285 0.1901778360 unevaluated
exp(x)*(x+2)/((x+1)^2*sqrt(x+3)) [0, 1] 1.0133117642 -1.8185227942 unevaluated
x*arsinh(sqrt(x)), 1/(x^2*sqrt(1+x)), x^2/((x+1)^3*sqrt(x+2)) right right, unchanged
exp(-x)*ln(1+sqrt(x)), exp(-x)*arsinh(x) unevaluated unevaluated

Master had 18 wrong answers here. This branch has none.

Cost. A decline searches longer than the wrong answer did. Taking the variable out early had cut the search short. The direct shapes take 0.7 to 5.4 s, where master took about 0.6 s. The arsinh(sqrt(x)) definite integrals do not return within the probe's 20 s. The issue's row, timed without a cap, took 35 s where the wrong 0 took 7.4 s. The indefinite exp(-x)*ln(sqrt(x+1)+sqrt(x)) takes 12.9 s, where master took 1.8 s. That is slower, but no longer wrong. Bounding that search is separate work.

Measured. Full unit suite: 22332 passed, 0 failed. F# wrapper: 135 passed. CasBench: 120/121 with 0 wrong, the same list as master. PropCheck: 1355 checks with 0 failures, the same as master. The integration and corpus tests on master: 3704 passed. BREAKING-CHANGES.md has an entry.

Fixes #2717

🤖 Generated with Claude Code

…nce as a constant

SolveANegativePowerOfALinearBesideAPowerOfAnotherByTheRecurrence moved every factor
whose base is free of the variable into its constant before looking at the exponent,
so e^x, 2^x and e^(-1/x) were taken out of the integral: e^x/(x^2 sqrt(1 + x)) was
answered as e^x times the antiderivative of 1/(x^2 sqrt(1 + x)). The check that an
exponent holds the variable came after, and never ran for a constant base.

Below integration by parts and the reciprocal substitution, the remainder of
e^(-x) arsinh(sqrt(x)) reaches e^(-1/u) (1 + u)^(-1/2)/u^2, and the wrong answer
for it made the whole antiderivative a constant: its derivative is 0, and the
definite integral was 0 on every interval, with exp(x), exp(-2x), arsinh(sqrt(2x)),
arcosh(sqrt(x + 1)) and ln(sqrt(x + a) + sqrt(x)) alike.

The exponent is now read first, and a factor with the variable in its exponent
declines the rule, as one with a variable base already did. These integrals are
not elementary (the remainder is an incomplete Bessel-type integral), so they are
left unevaluated; the issue's own definite integral searches 35 s before it
declines, against 7 s for the wrong 0. Every row of 24 generated variants is
right or unevaluated against mpmath's quadrature, where 18 were wrong.

Fixes #2717

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.73%. Comparing base (409d688) to head (847d9f5).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2741      +/-   ##
==========================================
+ Coverage   86.65%   86.73%   +0.07%     
==========================================
  Files         346      346              
  Lines       76959    76972      +13     
  Branches    22644    22648       +4     
==========================================
+ Hits        66692    66759      +67     
+ Misses       5534     5513      -21     
+ Partials     4733     4700      -33     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.22% <100.00%> (+0.07%) ⬆️
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 Δ
...Continuous/Integration/IndefiniteIntegralSolver.cs 87.21% <100.00%> (+0.12%) ⬆️

... and 15 files with indirect coverage changes

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

The definite integral of exp(-x) arsinh(sqrt(x)) is 0 on every interval

1 participant