Skip to content

Leave a limit whose phase keeps turning unevaluated, and keep the infinities whose argument settles - #2729

Open
Rafael-SOWNet wants to merge 4 commits into
masterfrom
fix-2708-turning-phase-declines
Open

Rafael-SOWNet wants to merge 4 commits into
masterfrom
fix-2708-turning-phase-declines

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

A constant to a growing power was read through its exponent's limit. That limit says how the modulus grows and nothing about the argument. exp(ln(x)^2) at -oo was +oo while its argument 2 pi ln|x| keeps turning. The gamma function off the real line turns as Im(z) ln|z|, so gamma(x + i) at +oo was +oo too.

  • Powf's descent keeps an infinity for a positive constant base only where the argument settles on an axis. That holds when the exponent is real near the point, or when what is left after its real addends has a finite limit: exp(x + pi i) is still -oo.
  • e^(k ln(w)) for a whole k > 0 is w^k, so it points where w's direction to the k does. w = b^g with b real and tending to 0 from one sign, and g tending to a negative c, points at c pi or 0. This is read from b and g, without asking w's whole limit.
  • Where the direction found is the infinity the parts already wrote, the descent hands on their form (e^(2 +oo)). The quotient that reads (e^(2 +oo) - 1)/(e^(2 +oo) + 1) as 1 keeps working.
  • Factorialf: gamma(h + v), with h real and growing, behaves as h! h^v. It points as e^L where v ln(h) -> L is finite, and declines otherwise. The Stirling route e^(lim ln H) keeps an infinite answer only for a real logarithm.
  • Divf: (E + a)/(E + b) is 1 for a growing constant power E and finite a, b, whatever E's argument does. This is tanh by its modulus.
  • Powf, for a positive constant base whose parts give no number or NaN: |b^g| = e^(Re(g) ln b). The real part of g is read by structure, and the answer is 0 where that tends to -oo. Since Compare the rates of a real and an imaginary infinity in a limit #2730, -(1 + i) x at +oo has no limit, so exp(-(1 + i) x), and with it tanh((1 + i) x) read by its modulus, were left unevaluated.
  • IsRealNear decides realness structurally. A power or logarithm of a base positive near the point counts (by SignNear), so exp(x^x) and gamma(x^(x/3)) stay answered.

Checked against mpmath (arg/pi at several scales; master is 9b75a2678):

limit master now
exp((1 + i) x), exp(x + i), exp(x + i ln(x)), 2^(x + i), gamma(x + i), gamma(x + i ln(x)), gamma(x + i sqrt(x)) at +oo +oo unevaluated
gamma(x + i/ln(x)) at +oo (settles at arg 1, off the axes) +oo unevaluated
exp(x + 2 i) at +oo -oo unevaluated
exp(ln(x)^2), gamma(ln(x)), exp(-x ln(x)) at -oo +oo unevaluated
exp(ln(x)/x), exp(ln(x)^2), gamma(-ln(x)) at 0- +oo unevaluated
gamma(ln(ln(x))), exp(1/x + i), gamma(1/x + i) at 0+ +oo unevaluated
exp((x - 1) ln(x)) at 0- +oo -oo
exp(-ln(x)/2) at 0- +oo -ooi
2^(x + pi i / ln(2)), gamma(x + pi i/ln(x)) at +oo +oo -oo
gamma(x + pi/2 i/ln(x)), gamma(x - pi/2 i/ln(x)) at +oo +oo +ooi, -ooi
exp(ln((1 + 1/x)^x)), exp(3 ln((1 + 1/x)^x)) at -1+ +oo -oo
exp(ln(x)/x) and two similar, at 0 two-sided NaN unevaluated
exp(-(1 + i) x), 2^(-(1 + i) x), (1/2)^((1 + i) x), exp(-x + i x^2), exp(i x - x) sin(x) at +oo (master a3f3b9ed1) unevaluated 0
tanh((1 + i) x), coth((1 + i) x), (exp((1 + i) x) - 1)/(exp((1 + i) x) + 3) at +oo (master a3f3b9ed1) unevaluated 1
gamma(x + i/x), gamma(x - i/x), gamma(x + i/sqrt(x)), gamma(x + 1/x), x tanh(ln((1 + 1/x)^x)) at -1, tanh(ln(x)^4) at -oo right unchanged

exp(x + pi i), exp(x + i/x), gamma(x) and the #2697 directions at 0- are also unchanged.

Merged with master 578680eed (#2730 and the rest). On that base, the 6314-limit sweep, compared with a master probe at a3f3b9ed1:

  • 12 wrong +oo and 3 NaN became unevaluated, as before.
  • 6 rows that time out on that probe are now answered correctly ((arsinh(x) - (x - x^3/6))/x^n and similar). These come from the master commits after a3f3b9ed1, not from this PR.
  • Total limit time: 935 s on the master probe and 860 s here, under a load average of 30-50.
  • Rows re-timed side by side are within noise. The exception is x - arcsin(x^2) at +oo: 0.22 s on the master probe, 0.40 s here.

#2730's 31 test rows give the same answers on both builds. Of 158 generated variants, mpmath finds no wrong answer here, against 32 on the master probe. 91 are right (79 on master) and 64 are declined (42 on master).

Still left alone: exp(-x + i x) x^5 at +oo is unevaluated on master and here. The 0 * oo product needs more than the modulus of the exponential.

Full unit suite on the merged tree: 22473 passed. The only failure, under a load average of ~50, was IntegralAnswerCacheTest.AnIntegralWithNoAnswerStillFinishesQuickly (57 s against a 30 s bound). That integral takes 6.7 s on both builds side by side, and the test passes when run alone. The three classes involved (this issue's, #2730's, and the integral cache test) pass: 86 of 86.

Fixes #2708

🤖 Generated with Claude Code

@codecov

codecov Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.32867% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.68%. Comparing base (578680e) to head (8f7f76e).

Files with missing lines Patch % Lines
...nctions/Continuous/Limits/Solvers/Limit.Classes.cs 70.71% 18 Missing and 23 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2729      +/-   ##
==========================================
- Coverage   86.70%   86.68%   -0.02%     
==========================================
  Files         346      346              
  Lines       77113    77255     +142     
  Branches    22699    22762      +63     
==========================================
+ Hits        66859    66969     +110     
- Misses       5533     5545      +12     
- Partials     4721     4741      +20     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.17% <71.32%> (-0.02%) ⬇️
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 Δ
...ath/Functions/Continuous/Limits/Transformations.cs 89.98% <100.00%> (+0.01%) ⬆️
...nctions/Continuous/Limits/Solvers/Limit.Classes.cs 78.85% <70.71%> (-1.67%) ⬇️

... and 4 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 and others added 2 commits December 6, 2026 03:23
…nt off the real line, and gamma along a path off it

A constant to a power whose exponent grows was read through the exponent's limit, and an infinite one gave an
infinity: ln(x)^2 at -oo is +oo, rightly, and exp(ln(x)^2) there was +oo where its argument 2 pi ln|x| keeps
turning. The modulus of b^g is e^Re(g ln b) and its argument Im(g ln b), so the exponent's limit says nothing about
the direction. Powf's descent now keeps an infinity for a positive constant base only where the argument settles on
an axis: the exponent is real near the point, or what is left once its addends real there are taken out has a finite
limit, as pi i in exp(x + pi i), which is -oo. Otherwise it declines, and the routes after it answer where they can:
exp((x - 1) ln(x)) at 0 from the left is now -oo, and exp(-ln(x)/2) there -ooi, both +oo before.

The gamma function along a path off the real line turns as Im(z) ln|z| by Stirling's formula, so the factorial's
descent keeps an infinity only for an argument real near the point, and the Stirling route that answers e^(lim ln H)
keeps an infinite one only where the logarithm is real: gamma(x + i) at +oo and gamma(ln(x)) at -oo were +oo.

Realness near the point is decided structurally by a new IsRealNear: a power or a logarithm of a base positive there
by SignNear, which keeps exp(x^x) and gamma(x^(x/3)) at +oo answered. Of the 6314 limits of the sweep that found
this, 18 answers changed: 14 wrong +oo are unevaluated, and so are three two-sided NaN with one turning side and
x tanh(ln((1 + 1/x)^x)) at -1, which needed only the modulus.

Fixes #2708

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… argument, a whole power through its logarithm, tanh by its modulus

The first commit declined three answers it did not need to. gamma(x + i/x) at +oo was left unevaluated because the
factorial kept an infinity only for an argument real near the point. Gamma of h + v, with h real and growing, is h!
times h^v to within a factor tending to 1, so its argument settles where v ln(h) has a finite limit L, and points as
e^L: gamma(x + i/x) is +oo again, gamma(x + pi i/ln(x)) is -oo and gamma(x + pi/2 i/ln(x)) +ooi, where master said +oo
for all three, and gamma(x + i/ln(x)), which settles at the argument 1, off the axes, is unevaluated.

x tanh(ln((1 + 1/x)^x)) at -1 was left unevaluated after four or five seconds. On the right of -1 it holds e^(2 ln(w))
with w = (1 + 1/x)^x tending to -oo, and the phase test declined because ln(w) is not real there. For a whole k > 0,
e^(k ln(w)) is w^k, single-valued, so it points as w's direction to the k. That direction is read from the base and
exponent of w, b^g with b real and tending to 0 from one sign and g real and tending to a negative c, at c pi or 0,
without asking the limit of w whole, which runs every solver on it. The descent also hands on the infinity in the form
the parts wrote it, e^(2 +oo), where the direction found is that infinity; the quotient that reads e^(2 +oo) - 1 over
e^(2 +oo) + 1 as 1 sees +oo - 1 over +oo + 1 as a form, and took a second through the routes after it. The row is -1
in the time master takes, and exp(ln(w)) and exp(3 ln(w)) there are -oo, both +oo on master.

tanh(ln(x)^4) at -oo, whose argument turns while its real part grows, went from 20 ms to 400 ms through the routes
after the descent, because e^(2z) is no answer there. (E + a) / (E + b), for a constant to a power E with 1/E tending to
0 and a and b finite, is 1 whatever E's argument does, and the quotient's descent now reads that.

Of the 6314 limits of the sweep, 15 answers differ from master 9b75a26: 12 wrong +oo and three NaN are unevaluated.
No row is slower by more than 3x and 300 ms; the sweep took 475 s of limit time against 490 s on master.

Part of #2708

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet force-pushed the fix-2708-turning-phase-declines branch from 7a2515e to e6cc17a Compare December 6, 2026 04:24
@Rafael-SOWNet Rafael-SOWNet changed the title Leave a limit whose phase keeps turning unevaluated: exp off the real line, and gamma along a complex path Leave a limit whose phase keeps turning unevaluated, and keep the infinities whose argument settles Dec 6, 2026
Rafael-SOWNet and others added 2 commits December 6, 2026 15:30
…ase-declines

# Conflicts:
#	BREAKING-CHANGES.md
…f the axes

Since #2730 an exponent tending to infinity off the axes, as -(1 + i) x at +oo, has no limit the library writes,
which is right: it is no direction. But its parts then gave e^(-oo - ooi), NaN, to Powf's descent, and exp(-(1 + i) x)
was left unevaluated where it is 0. tanh((1 + i) x) and (exp((1 + i) x) - 1) / (exp((1 + i) x) + 3), which this
branch reads as 1 by asking whether the inverse power vanishes, went unevaluated with it.

The modulus of b^g is e^(Re(g) ln b), so for a positive constant base the descent now takes the real part of the
exponent by its structure -- a sum by its addends, a product of a constant and a part real near the point by the
constant's real part -- and answers 0 where that times ln b tends to -oo, whatever the argument does. It is asked only
where the parts gave no number or NaN. exp(-(1 + i) x), 2^(-(1 + i) x), (1/2)^((1 + i) x), exp(-x + i x^2) and
exp(i x - x) sin(x) at +oo are 0, and tanh((1 + i) x) and coth((1 + i) x) 1 (|coth - 1| 2.4e-87 at x = 100, by
mpmath), all unevaluated on master a3f3b9e. #2730's 31 rows are unchanged.

Part of #2708

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

A limit whose phase keeps turning is answered +oo: exp((1 + i) x) at +oo, exp(ln(x)^2) at -oo, gamma(x + i) at +oo

1 participant