Skip to content

Take a limit over a constant as its dividend's limit over the constant (#2648) - #2651

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
constant-divisor-limit-2648
Nov 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
constant-divisor-limit-2648

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

The limit descent asked a quotient by a nonzero finite constant as a whole quotient first, through the solvers that rewrite it, and only afterwards asked its dividend. That ordering is what makes a definite integral of 1/(A + B sin(x)) across pi take seconds or never finish. Its antiderivative is c arctan((p tan(x/2) + q)/r) divided by an irrational constant, and the range is split at the pole of tan(x/2), where one-sided limits are taken.

Over a constant that is finite and not 0, the limit is now the dividend's limit over the constant, taken first. The dividend is asked as a whole limit, which is a smaller question, so a constant factor inside it is also taken out quickly. A dividend whose limit is undecided or undefined goes the long way, as before.

2.10.0 / master, within 20 s this branch
integral(1/(3+sin(x)), x, 0, 2 pi) does not finish sqrt(2) * pi / 2 (0.8 s)
integral(1/(3+sin(x)), x, 0, 5) does not finish closed form = 1.688760915039694383… (0.8 s)
integral(1/(4 - 3cos(x) + sin(x)), x, 2, 9) over 30 s closed form (0.4 s)
limit(4 arctan((6 tan(x/2) + 2)/(4 sqrt(2)))/(4 sqrt(2)), x, pi-) 17 s 0.4 s

Checks

  • Rational-trigonometric sweep: 120 random definite integrals against mpmath. Master gives 113 correct and 7 timeouts; this branch gives 120 correct and 0 wrong.
  • Rational sweep: 140 rational integrals over infinite ranges. Results are unchanged: 63 correct, 77 unevaluated, 0 wrong.
  • List diff: 223 definite integrals diffed against master, with no changes.
  • New test: runs the limit within a budget of 200 limits. It fails on master, where the quotient asked whole spends more than that.
  • Full UnitTests suite: 21849 passed, 0 failed, 13 skipped (net10.0).
  • Build: 0 errors for every target framework.

This changes Limit.Classes.cs, so the queued chain's limit harnesses are the measurement that matters most.

Closes #2648.

🤖 Generated with Claude Code

#2648)

The descent asked a quotient by a nonzero finite constant whole,
through the solvers that rewrite it, before it asked the dividend.
4 arctan((6 tan(x/2) + 2)/(4 sqrt(2))) / (4 sqrt(2)) at pi from the left
took seventeen seconds, where the dividend's limit takes a fraction of
one. The integral of 1/(3 + sin(x)) over a range across pi, which asks
that limit at the pole of tan(x/2), did not finish.

Over a constant that is finite and not 0, the limit is now the
dividend's limit over the constant, taken first. The dividend is asked
as a whole limit, which is a smaller question, so a constant factor
inside it is taken out quickly too. A dividend whose limit is undecided
or undefined goes the long way, as before.

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

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.72%. Comparing base (dccddc5) to head (572bcea).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2651      +/-   ##
==========================================
+ Coverage   86.71%   86.72%   +0.01%     
==========================================
  Files         346      346              
  Lines       75647    75664      +17     
  Branches    22114    22119       +5     
==========================================
+ Hits        65596    65620      +24     
+ Misses       5420     5413       -7     
  Partials     4631     4631              
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.22% <100.00%> (+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 Δ
...nctions/Continuous/Limits/Solvers/Limit.Classes.cs 78.71% <100.00%> (+0.17%) ⬆️

... and 10 files with indirect coverage changes

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

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(1/(3+sin(x)), x, 0, 2 pi) does not finish: the limit of a quotient by a constant goes through the solvers first

1 participant