Skip to content

Leave out of l'Hopital's rule what only makes the derivatives larger - #2377

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
feature/take-out-a-settling-factor-at-an-infinity
Nov 7, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
feature/take-out-a-settling-factor-at-an-infinity

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

l'Hopital's rule differentiates the whole of each side, and the product rule carries every factor beside the one it differentiates. A factor that only settles at a number, or a polynomial written on both sides, makes each round of derivatives larger, and with tanh written through exponentials some limits never finished. ln(x + tanh(x)) / ln((x - pi)^2) at +oo, which is 1/2, was still running after a minute.

Three changes, all in the limit code:

  • At an infinity, a factor that tends to a finite number other than 0 is replaced by that number, as a factor continuous at a finite point already was. A polynomial factor is left alone, since its limit is infinite.
  • A polynomial written on both sides is divided out before differentiating, when both sides still depend on x afterwards. A factor that is 0 everywhere is not cancelled: (x - x) sin(x) / ((x - x) x) at 0 stays NaN.
  • The quotient of two logarithms uses the limits of the four parts it is built from where they are finite and not 0. The derivative of x + tanh(x) tends to 2, and carrying it whole is what did not finish.

At an infinity the growth bound now measures what is actually differentiated, not the factors taken out. Without that, log(x, 1/2)^(e^x - sgn(x)) at 0+ went from 0.4 s to 9 s. At a finite point the bound is unchanged.

Input 2.6.0 / master This PR
ln(tanh(x) + x) / ln((x - pi)^2) at +oo did not finish in 30 s 1/2
ln(tanh(x) + x) / ln(x - pi) at +oo did not finish in 30 s 1
ln(arctan(x) + x) / ln(x) at +oo unevaluated 1
tanh(x) * x / (x + tanh(x)) at -oo did not finish in 30 s -1

Measured

  • Suite, wrappers, AOT and the harnesses are green.
  • limitcheck at DEPTH=3, across 39 seeds against master: five limits that did not finish in 5 s are answered, all correct. Examples are sinh(pi x) (1/x - 1) at 0, log(x + pi + erf(x), x^2 - tanh(-1)) at +oo and log((x - pi)^2, x + tanh(x)) at +oo.
  • Four cases timed out on the branch arm and not on master's: log(x, 1/2)^(e^x - sgn(x)) at 0+, x log(2 + x, x^3) at 0 from each side, (cos(x) sqrt(x))^arctan(tanh(x)) at 0+ and sinh(x)^3^tan(x) at 0-. Probed alone, each takes the same time on both builds: 2 s, 2.5 s, 7 s (unevaluated on both) and 74 ms. Rerun quietly, those four seeds report the same on both arms.

Still open, on master too

  • tanh(x) * x / (x + tanh(x)) and ln(tanh(x) + x^2) / ln(x) at +oo do not finish. Simplify writes tanh through e^(2x), which grows without bound, so no factor settles.
  • sinh(x)^3 ^ tan(x) at 0 from the left answers 0, where the values approach 1.

Found by limitcheck at DEPTH=3; no issue was filed.

🤖 Generated with Claude Code

The rule differentiates the whole of each side, and the product rule
carries every factor beside the one it differentiates. A factor that only
settles at a number, or a polynomial written on both sides, makes each
round larger, and with tanh written through exponentials
ln(x + tanh(x)) / ln((x - pi)^2) at +oo, which is 1/2, did not finish.

At an infinity a factor tending to a finite non-zero number is replaced
by that number, as a continuous factor at a finite point already was; a
polynomial on both sides is divided out when both still depend on x; and
the quotient of two logarithms uses the finite non-zero limits of its
four parts. The growth bound at an infinity measures what is
differentiated, not the factors taken out.

limitcheck DEPTH=3, 39 seeds: five limits that did not finish in 5 s
are answered, all correct; nothing else moved on a quiet rerun.

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

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.75%. Comparing base (4283f8b) to head (cf8559b).

Files with missing lines Patch % Lines
...ath/Functions/Continuous/Limits/Transformations.cs 91.11% 0 Missing and 4 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2377      +/-   ##
==========================================
- Coverage   86.77%   86.75%   -0.02%     
==========================================
  Files         312      312              
  Lines       68987    69033      +46     
  Branches    20112    20133      +21     
==========================================
+ Hits        59863    59893      +30     
- Misses       4918     4931      +13     
- Partials     4206     4209       +3     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.30% <92.30%> (-0.02%) ⬇️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

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.Solvers.cs 87.11% <100.00%> (+0.49%) ⬆️
...ath/Functions/Continuous/Limits/Transformations.cs 88.60% <91.11%> (+0.08%) ⬆️

... and 6 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 d205f72 into master Nov 7, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 7, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the feature/take-out-a-settling-factor-at-an-infinity branch November 7, 2026 01:57
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.

1 participant