Skip to content

Invert a power of the variable in a product l'Hôpital's rule reads at infinity - #2404

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
feature/limit-of-a-power-of-a-log-quotient
Nov 10, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
feature/limit-of-a-power-of-a-log-quotient

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Before l'Hôpital's rule reads a product of a vanishing factor and a diverging one, the product is rewritten as a quotient: the diverging factor goes on top and the reciprocal of the vanishing one underneath.

When the diverging factor is a power of the variable, each differentiation makes that quotient bigger. x^2 * ln(1 - 1/x) at +oo went to x^3 * ln(1 - 1/x)^2, then to x^4 * ln(1 - 1/x)^3, for three seconds. At an infinite destination the power is now inverted instead. Its reciprocal is another power, which differentiation lowers. The fix is in AsQuotientOfVanishingAndDiverging in Transformations.cs.

A vanishing factor that leaves the reals on the approach keeps the old arrangement. Otherwise (sqrt(x) - erf(x)) / x at 0 from the left answers a directed complex infinity, where master leaves it unevaluated.

Faster, same answers:

limit master this PR 2.6.0
x^2 * ln(1 - 1/x) at +oo 3.1 s 0.19 s 4.1 s
(-1 - x) / log(x, 2)^(x - 1) at 1, left 6.0 s 1.6 s 1.3 s
sinh((x - 1)^ln(x)) at 1, right 2.0 s 0.6 s 0.7 s
ln(1 + 1/x) * ln(1/x) at +oo 2.1 s 0.5 s 2.7 s
sin(x/2) / log(x, pi)^(x - 1) at 1, left 9.0 s, declines 2.1 s, declines 1.6 s, declines

Answered, where master declines:

limit this PR
x^2 * (1 - cos(1/x)) at +oo 1/2
x * abs(2/x) at +oo, -oo 2, -2
log(abs(-1/x), x) at +oo -1
log(x, x^3 / abs(x)) at 0, right 2
log(tanh(sin(x)), arcsin(x)/x) at 0 0
sinh(arctan(x))^sqrt(x*x) at 0, left 1
erf(e^x) * x * i at -oo 0
log(2 * (-1)^x, arcsin(x) / (2x)) at 0 -1 (master: NaN, wrong)

2.6.0 answers none of these, so no answer changes against it and there is no BREAKING-CHANGES entry.

Slower: tanh(log(arcsin(x), x)) at 0 from the left (and two-sided) goes from 2.8 s to 6.7 s, with the same answer; 2.6.0 declines it after 11 s.

  • Cause: inside it, x^3 * arccsc(-x) at +oo is now differentiated and reaches -oo, and its caller declines anyway.
  • Rejected alternative: inverting only where master's arrangement would also differentiate restored the 2.8 s, but lost x^2 * (1 - cos(1/x)). An answer seemed worth more than the time.
  • Separate gap: x * arccsc(-x) at +oo (-1) is declined at the top level on master and here.

The calculus tests pass, and so do the full suite (19235), the MCP, terminal, interactive and F# suites, the AOT build and every harness. limitcheck against master over all seeds shows only the rows above.

New test: APowerOfTheVariableIsInvertedTest.

🤖 Generated with Claude Code

… infinity

A product of something vanishing and something diverging is written as a
quotient before l'Hopital's rule reads it, the diverging factor on top and
the reciprocal of the vanishing one underneath. Where the diverging factor is
a power of the variable, that arrangement grows on every step: the reciprocal
of the vanishing factor squares it under differentiation, so
x^2 * ln(1 - 1 / x) at +oo went to x^3 * ln(1 - 1 / x)^2, then
x^4 * ln(1 - 1 / x)^3, for three seconds before answering -oo. The power is
inverted instead at an infinity, where its reciprocal is another power that
differentiating lowers.

A vanishing factor that leaves the reals on the approach keeps the old
arrangement. (sqrt(x) - erf(x)) / x at 0 from the left reaches here at +oo
with sqrt(-1 / x) in it, and over the power came out a directed complex
infinity where it is left unevaluated.

Faster, with the same answers: x^2 * ln(1 - 1 / x) at +oo 3.1 s to 0.19 s;
(-1 - x) / log(x, 2)^(x - 1) at 1 from the left 6.0 s to 1.6 s, which is
2.6.0's time again; sinh((x - 1)^ln(x)) at 1 from the right 2.0 s to 0.6 s;
ln(1 + 1 / x) * ln(1 / x) at +oo 2.1 s to 0.5 s.

And some that were declined are answered, because the inverted quotient
differentiates to something the rule can read: x^2 * (1 - cos(1 / x)) at +oo
is 1/2, x * abs(2 / x) at +oo and -oo is 2 and -2, log(x, x^3 / abs(x)) at 0
from the right is 2, and log(2 * (-1)^x, arcsin(x) / (2 * x)) at 0 is -1,
where master said NaN. 2.6.0 answers none of them.

tanh(log(arcsin(x), x)) at 0 from the left is slower, 2.8 s to 6.7 s, same
answer (2.6.0 declines it after 11 s): x^3 * arccsc(-x) inside it is now
differentiated, and the caller declines the result. Only inverting where the
old arrangement would differentiate too gave that time back, and lost
x^2 * (1 - cos(1 / x)).

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

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.81%. Comparing base (e8b0995) to head (4ede03c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2404      +/-   ##
==========================================
- Coverage   86.81%   86.81%   -0.01%     
==========================================
  Files         312      312              
  Lines       69339    69342       +3     
  Branches    20235    20237       +2     
==========================================
+ Hits        60195    60197       +2     
- Misses       4917     4919       +2     
+ Partials     4227     4226       -1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.35% <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.27% <100.00%> (+0.16%) ⬆️

... and 3 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 a9c0191 into master Nov 10, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 10, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the feature/limit-of-a-power-of-a-log-quotient branch November 10, 2026 02:11
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