Skip to content

Read a limit that is 0 written another way as 0 (#2639) - #2655

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
zero-limit-in-another-form-2639
Nov 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
zero-limit-in-another-form-2639

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

#2632 reads a limit that comes back as a constant minus itself as 0. A zero written any other way was still kept as a nonzero constant. A quotient over a vanishing divisor then answered NaN, or +oo times that constant.

The fix. CancelledDifference now asks one more question of a constant sum that is free of x and of infinities: does Simplify reduce it to 0? Any condition Simplify attaches is kept. The check is applied to Sumf's descent results, as it already was to Minusf's. ParseAsPolynomial drops a coefficient that reduces to 0.

.Limit(x, 0) master / 2.10.0 this branch
(tan(a + x) - tan(a)) / x NaN 1 / cos(a) ^ 2
(cosh(a x) - 1) / x^2 NaN a ^ 2 * 2 / 4
(cosh(a x) - 1) / x 1/2 * a + -1/2 * a 0
(artanh(a + x) - artanh(a)) / x NaN (-1) / (a ^ 2 + -1)
(((a + x)^2)^2 - a^4) / x +oo * (-a ^ 4 + a ^ 4) 4 * a ^ 3

The same holds for the difference quotients of cot, sec, csc and arcosh.

How it was found. A new sweep, symlimitcheck, takes 190 limits at a symbolic point or with a symbolic parameter. It compares each answer by value at a = -5/2, -7/10, 3/5, 19/10 and 33/10 against the values approaching the point, and against the library's own limit taken with that value of a put in first. On master it reports 82 rows of NaN where the values settle; on this branch it reports 12. The rest are left as they were:

  • abs difference quotients are NaN, by a separate mechanism (a step near the point).
  • x^a at 0+ gives 0 with a condition that is false for a < 0.
  • a^x / x at +oo is NaN.
  • For a on the branch cut (a = -5/2), the arcsin and arccos difference quotients give the derivative's other sign. This is the sweep's only "another value" row, and it is the same on master and on this branch.

Checks

  • The new test AZeroLimitWrittenAnotherWayTest takes each limit from both sides and from each side alone, and compares it by value at three values of a.
  • limitcheck reports the same findings as master.
  • The full UnitTests suite passed: 21814 passed, 13 skipped, 0 failed. The library builds for every target framework.
  • I timed the Calculus tests twice on each tree: master took 3 min 24 s and 3 min 9 s, this branch 2 min 55 s and 3 min 48 s. That spread is within the noise.

.editorconfig gains one entry: the 2026 header template for the new test file, which IDE0073 requires.

Closes #2639.

🤖 Generated with Claude Code

#2632 reads a limit that comes back as a constant minus itself as 0. A zero
written any other way was still kept as a nonzero constant: the limit of
tan(a + x) - tan(a) at 0 comes back sin(a) / cos(a) - tan(a), one step of
l'Hopital's rule on (cosh(a x) - 1) / x^2 leaves 1/2 a + -1/2 a, and the
difference quotients of tan, cot, sec, csc, artanh and arcosh at a symbolic
point were NaN for it. A polynomial's constant coefficient written
-a^4 + a^4 made (((a + x)^2)^2 - a^4) / x answer +oo times it.

CancelledDifference now also asks a constant sum, free of x and of
infinities, whether Simplify reduces it to 0, keeping a condition Simplify
attaches. It is applied to Sumf's descent results as Minusf's already were,
and ParseAsPolynomial drops a coefficient it reduces to 0.

Found by a sweep of limits at symbolic points and with symbolic parameters
compared by value at five values of the parameter: on master it reports 82
rows of NaN where the values settle, on this branch 12.

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

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.70%. Comparing base (a1b69bf) to head (515d303).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...nctions/Continuous/Limits/Solvers/Limit.Solvers.cs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2655      +/-   ##
==========================================
- Coverage   86.70%   86.70%   -0.01%     
==========================================
  Files         345      346       +1     
  Lines       75541    75734     +193     
  Branches    22075    22148      +73     
==========================================
+ Hits        65501    65666     +165     
- Misses       5416     5430      +14     
- Partials     4624     4638      +14     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.20% <94.44%> (-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.83% <100.00%> (+0.28%) ⬆️
...ns/Continuous/Limits/Solvers/Solvers.Definition.cs 92.26% <100.00%> (+0.17%) ⬆️
...nctions/Continuous/Limits/Solvers/Limit.Solvers.cs 89.61% <50.00%> (-0.35%) ⬇️

... and 20 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 cc86a04 into master Nov 29, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 29, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the zero-limit-in-another-form-2639 branch November 29, 2026 12:05
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.

A limit at a symbolic point is NaN where its numerator tends to a zero not written as u - u: (tan(a+x) - tan(a))/x

1 participant