Skip to content

Commit 598dae9

Browse files
Read the limit of a modulus as the quotient or product of moduli (#2371)
abs(1/x^pi) at 0 was NaN, the claim that the limit does not exist, where it is +oo from both sides, as 1/abs(x)^pi is. The modulus took its argument's limit and nothing else. To the left of 0, x^pi is complex, so the sign 1/x^pi's divisor vanishes with could not be read: that side had no limit, and the two-sided limit was NaN. The same on 2.6.0. Where the argument's limit gives the modulus no value, the modulus of a quotient is now read as the quotient of the moduli, and of a product as the product. Both hold for complex values. Read that way, the divisor vanishes from above, which the vanishing-divisor reading already answers. abs(log(cos(x), -1)) at 0, which is pi / abs(ln(cos(x))), is +oo for the same reason. limitcheck at DEPTH=3, 21 seeds 14-51, master against this: 3 more compared over 2 seeds, the two NaNs above answered, and nothing else changed. Suite 18988 passed, AOT and the eight harnesses clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fdc586f commit 598dae9

3 files changed

Lines changed: 79 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,23 @@ gives is taken. No issue was filed.
499499
| `limit(exp((cos(x) - 1)/x^2), x, 0)` | `NaN` | `e ^ (-1/2)` |
500500
| `limitright(exp(sin(x)/x), x, 0)` | unevaluated | `e` |
501501

502+
### A limit of a modulus reads it as the quotient or product of moduli
503+
504+
**Silent: `abs(1/x^pi)` at 0 is `+oo`, where it was `NaN`, the claim that the limit does not exist.** The modulus took its
505+
argument's limit and nothing else. To the left of 0, `x^pi` is complex, so the sign `1/x^pi`'s divisor vanishes with
506+
could not be read: that side had no limit, and the two-sided limit was `NaN`. Where the argument's limit gives the
507+
modulus no value, the modulus of a quotient is now read as the quotient of the moduli, and of a product as the
508+
product. This holds for complex values too, and read that way the divisor vanishes from above.
509+
510+
| Input | Was (2.6.0) | Now |
511+
|---|---|---|
512+
| `"abs(1/x^pi)".ToEntity().Limit("x", 0)` | `NaN` | `+oo` |
513+
| `"abs(1/x^pi)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(abs(1 / x ^ pi), x, 0)` | `+oo` |
514+
| `"abs(1/sqrt(x))".ToEntity().Limit("x", 0)` | `NaN` | `+oo` |
515+
| `"abs(2/x^(3/2))".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(abs(2 / x ^ (3/2)), x, 0)` | `+oo` |
516+
| `"abs(log(cos(x), -1))".ToEntity().Limit("x", 0)` | `NaN` | `+oo` |
517+
| `"abs(log(cos(x), -1))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(abs(log(cos(x), -1)), x, 0)` | `+oo` |
518+
502519
### A two-sided limit of an expression real on both sides is where its sides agree
503520

504521
**Silent: a two-sided limit that was `NaN` although both sides agree has their value, where the expression is real on

‎Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,24 @@ partial record Signumf
539539
partial record Absf
540540
{
541541
internal override Entity? ComputeLimitDivideEtImpera(Variable x, Entity dist, ApproachFrom side)
542-
=> Argument.ComputeLimitDivideEtImpera(x, dist, side)?.Abs();
542+
{
543+
var direct = Argument.ComputeLimitDivideEtImpera(x, dist, side)?.Abs();
544+
if (direct is { } found && found.Evaled != MathS.NaN)
545+
return found;
546+
// The modulus of a quotient is the quotient of the moduli, and of a product the product,
547+
// for complex values as for real ones. Read that way, a divisor that vanishes vanishes from
548+
// above: abs(1/x^pi) at 0 from the left had no limit, x^pi being complex there and its
549+
// sign unreadable, so the two-sided limit was NaN where it is +oo, as 1/abs(x)^pi is.
550+
Entity? split = Argument switch
551+
{
552+
Divf(var dividend, var divisor) => dividend.Abs() / divisor.Abs(),
553+
Mulf(var multiplier, var multiplicand) => multiplier.Abs() * multiplicand.Abs(),
554+
_ => null
555+
};
556+
return split?.ComputeLimitDivideEtImpera(x, dist, side) is { } bySplitting && bySplitting.Evaled != MathS.NaN
557+
? bySplitting
558+
: direct;
559+
}
543560
}
544561

545562
/// <summary>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Copyright (c) 2019-2026 Angouri.
3+
// AngouriMath is licensed under MIT.
4+
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
5+
// Website: https://am.angouri.org.
6+
//
7+
8+
using AngouriMath.Core;
9+
using Xunit;
10+
11+
namespace AngouriMath.Tests.Calculus
12+
{
13+
/// <summary>
14+
/// <c>abs(1/x^pi)</c> at 0 was NaN -- the claim that the limit does not exist -- where it is +oo from both sides, as
15+
/// <c>1/abs(x)^pi</c> is. The modulus took its argument's limit and nothing else, and to the left of 0 <c>x^pi</c> is
16+
/// complex, so the sign <c>1/x^pi</c>'s divisor vanishes with could not be read: that side had no limit, and the
17+
/// two-sided limit was NaN. The modulus of a quotient is the quotient of the moduli, and of a product the product,
18+
/// for complex values too, and read that way the divisor vanishes from above. The same on 2.6.0. Found by limitcheck
19+
/// at <c>DEPTH=3</c>, <c>SEED=51</c>, and <c>abs(log(cos(x), -1))</c>, which is pi / abs(ln(cos(x))), at
20+
/// <c>SEED=41</c>; no issue was filed.
21+
/// </summary>
22+
[Trait("Area", "Calculus")]
23+
public sealed class AModulusOfAQuotientTest
24+
{
25+
[Theory]
26+
[InlineData("abs(1/x^pi)")]
27+
[InlineData("abs(2/x^(3/2))")]
28+
[InlineData("abs(1/sqrt(x))")]
29+
[InlineData("abs(log(cos(x), -1))")]
30+
public void IsInfiniteFromEachSideAndBoth(string input)
31+
{
32+
foreach (var side in new[] { ApproachFrom.Left, ApproachFrom.Right, ApproachFrom.BothSides })
33+
Assert.Equal(MathS.FromString("+oo"), MathS.FromString(input).Limit("x", 0, side));
34+
}
35+
36+
// A modulus that has a limit as written keeps it.
37+
[Theory]
38+
[InlineData("abs(sin(x)/x)", "0", "1")]
39+
[InlineData("abs(x/abs(x))", "0", "1")]
40+
[InlineData("abs((x^2 - 1)/(x - 1))", "1", "2")]
41+
public void KeepsWhatItHad(string input, string destination, string expected)
42+
=> Assert.Equal(MathS.FromString(expected), MathS.FromString(input).Limit("x", destination));
43+
}
44+
}

0 commit comments

Comments
 (0)