Skip to content

Ask a quotient factor whole before l'Hopital's rule splits it - #2382

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
feature/tanh-quotient-at-infinity
Nov 7, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
feature/tanh-quotient-at-infinity

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

tanh(x) * x / (x + tanh(x)) at +oo is 1, but the limit did not finish (60 s on 2.6.0, 30 s on master).

l'Hopital's rule takes out a factor that tends to a finite number other than 0, since differentiating only carries it along (#2377). It read the factors after flattening the product, and flattening takes a quotient apart. tanh(x) written through exponentials is (e^(2x) - 1) / (e^(2x) + 1): the whole tends to 1, but its parts tend to +oo and to 0, so neither was taken out and the whole of tanh was differentiated over and over.

A quotient factor is now asked whole first, and split only when the whole does not settle at such a number.

Input 2.6.0 master This PR
tanh(x) * x / (x + tanh(x)), +oo did not finish in 60 s did not finish in 30 s 1 (0.35 s)

At -oo the limit is still -1. #2377's code comment named this case but tested only -oo; this PR adds +oo to LhopitalKeepsTheDerivativesSmallTest.

Measured

  • Suite, wrappers, AOT and the harnesses are green.
  • limitcheck at DEPTH=3, across 42 seeds against master: identical on every seed. The generator does not build this quotient shape, so the test is the evidence for the change.

Found while tracing a limitcheck row; no issue was filed.

🤖 Generated with Claude Code

l'Hopital's rule takes out of each side a factor that tends to a finite
number other than 0, since the product rule only carries it along. The
factors were read after flattening the product, which takes a quotient
apart: tanh(x) written through exponentials is (e^(2x) - 1) / (e^(2x) + 1),
which tends to 1 at +oo, while its parts tend to +oo and to 0 and neither
was taken out. tanh(x) * x / (x + tanh(x)) at +oo then differentiated the
whole of tanh and did not finish.

A quotient is now asked whole first, and taken apart only where it does
not settle at such a number.

tanh(x) * x / (x + tanh(x)) at +oo: did not finish in 60 s -> 1.

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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.77%. Comparing base (50e9403) to head (5b1147f).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2382      +/-   ##
==========================================
- Coverage   86.77%   86.77%   -0.01%     
==========================================
  Files         312      312              
  Lines       69095    69107      +12     
  Branches    20151    20155       +4     
==========================================
+ Hits        59957    59967      +10     
- Misses       4921     4923       +2     
  Partials     4217     4217              
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.31% <100.00%> (-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.60% <100.00%> (+0.19%) ⬆️

... 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 2e2bf9d 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/tanh-quotient-at-infinity branch November 7, 2026 14:25
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