Skip to content

Take a factor continuous at the point out before l'Hopital's rule - #2370

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
fix/a-continuous-factor-is-not-differentiated
Nov 4, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
fix/a-continuous-factor-is-not-differentiated

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

sin(x)^tanh(x) at 0 from the right was left unevaluated, where it is 1. tan(2x)^sin(tanh(x)) declined after 13 s, and 2.6.0 does not finish it in 2 minutes.

Read through its exponent, the power becomes a quotient that l'Hôpital's rule takes. The rule differentiated every factor of both parts. That included factors tending to a non-zero number, such as the 1 - tanh(x)^2 that tanh's derivative brings. tanh is written through exponentials, so each such factor doubled the derivative, which then outgrew the rule's bound.

Now a factor that is continuous at a finite destination, with a finite, non-zero real value there, is taken out as that value and kept exact: lim c(x) f(x)/g(x) = c(a) lim f(x)/g(x).

  • Only a factor that TreeAnalyzer.IsRealValued says is real for real x, and that has no floor, ceil, round, sign or piecewise in it. So its value at the point is its limit from either side.
  • A limit that is an infinity stays that infinity. A finite one is the exact product, so tanh(1 + x)·(x - 1)/(x^2 - 1) at 1 is (e^4 - 1)/(2(e^4 + 1)) and not a decimal.
Input, at 0⁺ 2.6.0 master Now
sin(x)^tanh(x) unevaluated unevaluated 1
tan(x)^sin(tanh(x)) unevaluated unevaluated 1
tan(2*x)^sin(tanh(x)) did not finish in 2 min unevaluated after 13 s 1, in 0.4 s

Measured

  • limitcheck at DEPTH=3 on 18 seeds (14 to 45), master against this branch: 10 more rows compared across 6 seeds, and 4 fewer that did not finish in 5 s. No row moved to another value or to NaN.
  • The new tests fail on master: the three rows above. The three rows that check the value taken out pass on both.
  • Suite: 18982 passed, 0 failed. AOT passed. BoundCheck, RootCheck, CasBench, PropCheck, SimpSweep, RuleCheck, CanonCheck and Confluence are clean.

Not fixed here: (1 - tanh(x)^2)·x·(1 + x^2)/tanh(x) at 0⁺ still takes about 19 s. Nearly all of that is Simplify on the expression itself, which takes 7 s without any limit. That is a separate defect.

Found by limitcheck at seed 42. Recorded in BREAKING-CHANGES.md.

🤖 Generated with Claude Code

sin(x)^tanh(x) at 0 from the right was left unevaluated, where it is 1,
and tan(2x)^sin(tanh(x)) declined after thirteen seconds (2.6.0 does not
finish it in two minutes). Read through its exponent, the power is a
quotient the rule takes, and the rule differentiated every factor of
both parts, including those that tend to a number other than 0, such as
the 1 - tanh(x)^2 that tanh's derivative brings. With tanh written
through exponentials, each such factor doubled the derivative, and it
outgrew the rule's bound.

A factor that is continuous at a finite destination and has a finite,
non-zero real value there is now taken out as that value, kept exact:
lim c(x) f(x) / g(x) is c(a) lim f(x) / g(x). Only a factor real for
real x and with no step in it, so that its value at the point is its
limit from either side. A limit that is an infinity stays that
infinity.

limitcheck at DEPTH=3, 18 seeds 14-45, master against this: 10 more
compared over 6 seeds, 4 fewer that did not finish in 5 s, and nothing
moved to another value or to NaN. Suite 18982 passed, AOT and the eight
harnesses clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Nov 4, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Nov 4, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.75%. Comparing base (4c203f0) to head (4a4e752).

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2370   +/-   ##
=======================================
  Coverage   86.75%   86.75%           
=======================================
  Files         312      312           
  Lines       68877    68897   +20     
  Branches    20071    20078    +7     
=======================================
+ Hits        59755    59774   +19     
+ Misses       4926     4925    -1     
- Partials     4196     4198    +2     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.30% <95.65%> (+<0.01%) ⬆️
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 Δ
...ath/Functions/Continuous/Limits/Transformations.cs 88.05% <95.65%> (+0.22%) ⬆️

... and 9 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 fdc586f into master Nov 4, 2026
33 of 35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Nov 4, 2026
@Rafael-SOWNet

Copy link
Copy Markdown
Member Author

Merged without the two macOS jobs. They were cancelled before they started ("The job was not acquired by Runner of type hosted even after multiple attempts"), the same macOS arm64 outage as on #2368 and #2369. In their place:

  • I ran this PR's rows on a 512 KB thread, the tightest stack the macOS leg gives, along with x * ln(x) and Ask the whole limit of a quotient of two infinities in the descent #2369's e^log(1/x, arcsin(x)). Each limit came out as the tests expect.
  • The branch sits on current master, so there was nothing to trial-merge.
  • Every Linux and Windows check is green.
  • The local chain, suite and harnesses all passed.

@Rafael-SOWNet
Rafael-SOWNet deleted the fix/a-continuous-factor-is-not-differentiated branch November 4, 2026 18:37
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