Skip to content

Commit 9d499b8

Browse files
Ask a product with a quotient factor over that quotient's divisor in a one-sided limit (#2384)
From one side, a product whose factors tend to 0 and to an infinity, one of them a quotient, is asked as that quotient with the other factor in its dividend, its whole limit once. Read as a product nothing settled the form, and the rewriting solvers took x * (ln(x) / ln(2 + x)) at 0 from the right through l'Hopital's rule for longer than any caller waits, where x ln(x) / ln(2 + x) is 0 at once. Not while the sides of a two-sided limit are compared, as powers already are not: x * ln(x) / ln(2 + x) at 0 is NaN two-sided, its left side being complex, and the same product written with brackets would have come back 0. Measured on master -> this branch, one probe each: x * log(2 + x, x) at 0+ timeout (30 s) -> 0, 0.24 s x * log(2 + x, x) at 0- 0 in 11.8 s -> 0.26 s x * (ln(-x) / ln(2 + x)) at 0- 0 in 11.7 s -> 0.25 s x * log(2 + x, x^3) at 0+ 0 in 1.15 s -> 0.26 s (x - 1) * (ln(x - 1) / ln(x + 1)) at 1+ 0 in 0.69 s -> 0.27 s Two-sided answers are unchanged (x * log(2 + x, x) at 0 is NaN on both). Found by limitcheck at DEPTH=3, SEED=59, under the logarithm-of-a-power change, which writes ln(x^3) / ln(2 + x) as 3 ln(x) / ln(2 + x) and so reached this. No issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0f2f41d commit 9d499b8

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ A not-equal written `<>` is read as `not (a = b)`, and printed that way.
4242

4343
## Unreleased — since 2.6.0
4444

45+
### A product with a quotient for a factor is read over that quotient's divisor in a one-sided limit
46+
47+
**Silent: a one-sided limit of a product whose factors tend to 0 and to an infinity, one of them a quotient, is asked
48+
as that quotient with the other factor in its dividend.** Read as a product nothing settled the form. Some of these
49+
were left unevaluated, and some took half a minute through l'Hôpital's rule for what the same expression over one
50+
divisor answers at once. A two-sided limit is not changed. Found by limitcheck; no issue was filed.
51+
52+
| Input | Was (2.6.0) | Now |
53+
|---|---|---|
54+
| `"sin(ln(x) * x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sin(ln(x) * x), x, 0)` | `0` |
55+
| `"floor(x * log(pi, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(floor(x * log(pi, x)), x, 0)` | `-1` |
56+
| `"sgn(sin(x) * log(pi, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sgn(sin(x) * log(pi, x)), x, 0)` | `-1` |
57+
| `"arcsin(-x * log(-1, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(arcsin(-x * log(-1, x)), x, 0)` | `0` |
58+
| `"x * log(2 + x, x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `0` after 27 s | `0` in 0.25 s |
59+
4560
### A limit at the jump of a step function is not answered by substitution
4661

4762
**Silent: a limit of an expression built on `floor`, `ceil`, `round` or `sgn`, where the step's argument arrives on one

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@ partial record Mulf
7979
return byMultiplier;
8080
if (AnInfinityTimesASign(Multiplicand, Multiplier, multiplierLimit, dividing: false, x, dist, side) is { } byMultiplicand)
8181
return byMultiplicand;
82+
// 0 * oo from one side, with a quotient for one factor, is asked as that quotient
83+
// with the other factor in its dividend, its whole limit once. Read as a product,
84+
// nothing settles the form, and the rewriting solvers took x * (ln(x) / ln(2 + x)) at
85+
// 0 from the right through l'Hopital's rule for longer than any caller waits, where
86+
// (x ln(x)) / ln(2 + x) is 0 at once. One-sided only, and not while the sides of a
87+
// two-sided limit are compared: two-sided, x * ln(x) / ln(2 + x) at 0 is NaN, its
88+
// left side being complex, and regrouped there the same product written with
89+
// brackets came back 0.
90+
if (side is not ApproachFrom.BothSides && !IsComparingSides
91+
&& multiplierLimit is { } zeroOrInfinity1 && multiplicandLimit is { } zeroOrInfinity2
92+
&& IsZeroTimesAnInfinity(zeroOrInfinity1, zeroOrInfinity2)
93+
&& (Multiplicand, Multiplier) switch
94+
{
95+
(Divf(var dividend, var divisor), var other) => new Divf(other * dividend, divisor),
96+
(var other, Divf(var dividend, var divisor)) => new Divf(dividend * other, divisor),
97+
_ => null
98+
} is { } regrouped
99+
&& AsTheWholeLimit(regrouped, x, dist, side) is { } overOneDivisor
100+
&& overOneDivisor.Evaled != MathS.NaN)
101+
return overOneDivisor;
82102
var (mp, md) =
83103
(multiplierLimit, multiplicandLimit) switch
84104
{
@@ -206,6 +226,15 @@ private static bool IsAnIndeterminateQuotient(Entity dividend, Entity divisor)
206226
_ => false,
207227
};
208228

229+
/// <summary>Whether two factors' limits make a product 0 * oo.</summary>
230+
private static bool IsZeroTimesAnInfinity(Entity first, Entity second)
231+
=> (first.Evaled, second.Evaled) switch
232+
{
233+
(Complex { IsZero: true }, Number { IsFinite: false, IsNaN: false }) => true,
234+
(Number { IsFinite: false, IsNaN: false }, Complex { IsZero: true }) => true,
235+
_ => false,
236+
};
237+
209238
/// <summary>The quotient whose whole limit is being asked from inside the descent, so that no other is asked inside it.</summary>
210239
[System.ThreadStatic] private static HashSet<Entity>? quotientsAskedWhole;
211240

‎Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ bool PositiveOnBothSides(Entity node)
298298
internal static bool MayReadAPowerThroughItsExponent(Entity power)
299299
=> !comparingSides && !ReferenceEquals(power, descentRoot);
300300

301+
/// <summary>
302+
/// Whether the descent is reading the two sides of a two-sided limit to compare them. A
303+
/// side read there is not that side's question, and a product regrouped there would decide
304+
/// a two-sided limit with a complex side that the comparison leaves undecided.
305+
/// </summary>
306+
internal static bool IsComparingSides => comparingSides;
307+
301308
/// <summary>
302309
/// Whether <paramref name="expr"/> is the whole of the question whose descent is under
303310
/// way. The path that began the descent asks the rest of the machinery of it once the
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 System;
9+
using System.Threading.Tasks;
10+
using AngouriMath.Core;
11+
using AngouriMath.Extensions;
12+
using Xunit;
13+
14+
namespace AngouriMath.Tests.Calculus
15+
{
16+
/// <summary>
17+
/// A product whose factors tend to 0 and to an infinity, one of them a quotient, from one side.
18+
/// Read as a product nothing settled the form, and x * (ln(x) / ln(2 + x)) at 0 from the right
19+
/// did not finish in thirty seconds, nor did x * log(2 + x, x), where x ln(x) / ln(2 + x), the
20+
/// same thing over one divisor, was 0 at once; from the left each took twelve seconds. Found
21+
/// by limitcheck at <c>DEPTH=3</c>, <c>SEED=59</c>; no issue was filed.
22+
/// </summary>
23+
[Trait("Area", "Calculus")]
24+
public sealed class AProductWithAQuotientFactorTest
25+
{
26+
[Theory]
27+
[InlineData("x * (ln(x) / ln(2 + x))", "0", ApproachFrom.Right)]
28+
[InlineData("(ln(x) / ln(2 + x)) * x", "0", ApproachFrom.Right)]
29+
[InlineData("x * log(2 + x, x)", "0", ApproachFrom.Right)]
30+
[InlineData("x * log(2 + x, x)", "0", ApproachFrom.Left)]
31+
[InlineData("sin(x) * (ln(x) / ln(3 - x))", "0", ApproachFrom.Right)]
32+
[InlineData("x * (ln(-x) / ln(2 + x))", "0", ApproachFrom.Left)]
33+
public void IsZero(string expr, string at, ApproachFrom side)
34+
{
35+
var asked = Task.Run(() => expr.ToEntity().Limit("x", at, side));
36+
Assert.True(asked.Wait(TimeSpan.FromSeconds(20)), $"the limit of {expr} at {at} from the {side} did not finish");
37+
var limit = asked.Result;
38+
Assert.DoesNotContain(limit.Nodes, node => node is Entity.Limitf);
39+
Assert.Equal(Entity.Number.Integer.Zero, limit.Simplify());
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)