From 91d771be56d98e315bb0ab00d67d0e23605f822a Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sat, 7 Nov 2026 20:39:53 +0000 Subject: [PATCH 1/2] Ask a product with a quotient factor over that quotient's divisor in a limit 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 --- .../Limits/Solvers/Limit.Classes.cs | 29 +++++++++++++ .../Limits/Solvers/Solvers.Definition.cs | 7 ++++ .../AProductWithAQuotientFactorTest.cs | 42 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 Sources/Tests/UnitTests/Calculus/AProductWithAQuotientFactorTest.cs diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs index 1125bbea9..fd7d241fd 100644 --- a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs +++ b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs @@ -79,6 +79,26 @@ partial record Mulf return byMultiplier; if (AnInfinityTimesASign(Multiplicand, Multiplier, multiplierLimit, dividing: false, x, dist, side) is { } byMultiplicand) return byMultiplicand; + // 0 * oo from one side, with a quotient for one factor, is asked as that quotient + // with the other factor in its dividend, its whole limit once. Read as a product, + // nothing settles 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. One-sided only, and not while the sides of a + // two-sided limit are compared: two-sided, x * ln(x) / ln(2 + x) at 0 is NaN, its + // left side being complex, and regrouped there the same product written with + // brackets came back 0. + if (side is not ApproachFrom.BothSides && !IsComparingSides + && multiplierLimit is { } zeroOrInfinity1 && multiplicandLimit is { } zeroOrInfinity2 + && IsZeroTimesAnInfinity(zeroOrInfinity1, zeroOrInfinity2) + && (Multiplicand, Multiplier) switch + { + (Divf(var dividend, var divisor), var other) => new Divf(other * dividend, divisor), + (var other, Divf(var dividend, var divisor)) => new Divf(dividend * other, divisor), + _ => null + } is { } regrouped + && AsTheWholeLimit(regrouped, x, dist, side) is { } overOneDivisor + && overOneDivisor.Evaled != MathS.NaN) + return overOneDivisor; var (mp, md) = (multiplierLimit, multiplicandLimit) switch { @@ -206,6 +226,15 @@ private static bool IsAnIndeterminateQuotient(Entity dividend, Entity divisor) _ => false, }; + /// Whether two factors' limits make a product 0 * oo. + private static bool IsZeroTimesAnInfinity(Entity first, Entity second) + => (first.Evaled, second.Evaled) switch + { + (Complex { IsZero: true }, Number { IsFinite: false, IsNaN: false }) => true, + (Number { IsFinite: false, IsNaN: false }, Complex { IsZero: true }) => true, + _ => false, + }; + /// The quotient whose whole limit is being asked from inside the descent, so that no other is asked inside it. [System.ThreadStatic] private static HashSet? quotientsAskedWhole; diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs index 83cabc536..8a17942f3 100644 --- a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs +++ b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs @@ -298,6 +298,13 @@ bool PositiveOnBothSides(Entity node) internal static bool MayReadAPowerThroughItsExponent(Entity power) => !comparingSides && !ReferenceEquals(power, descentRoot); + /// + /// Whether the descent is reading the two sides of a two-sided limit to compare them. A + /// side read there is not that side's question, and a product regrouped there would decide + /// a two-sided limit with a complex side that the comparison leaves undecided. + /// + internal static bool IsComparingSides => comparingSides; + /// /// Whether is the whole of the question whose descent is under /// way. The path that began the descent asks the rest of the machinery of it once the diff --git a/Sources/Tests/UnitTests/Calculus/AProductWithAQuotientFactorTest.cs b/Sources/Tests/UnitTests/Calculus/AProductWithAQuotientFactorTest.cs new file mode 100644 index 000000000..349872850 --- /dev/null +++ b/Sources/Tests/UnitTests/Calculus/AProductWithAQuotientFactorTest.cs @@ -0,0 +1,42 @@ +// +// Copyright (c) 2019-2026 Angouri. +// AngouriMath is licensed under MIT. +// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md. +// Website: https://am.angouri.org. +// + +using System; +using System.Threading.Tasks; +using AngouriMath.Core; +using AngouriMath.Extensions; +using Xunit; + +namespace AngouriMath.Tests.Calculus +{ + /// + /// A product whose factors tend to 0 and to an infinity, one of them a quotient, from one side. + /// Read as a product nothing settled the form, and x * (ln(x) / ln(2 + x)) at 0 from the right + /// did not finish in thirty seconds, nor did x * log(2 + x, x), where x ln(x) / ln(2 + x), the + /// same thing over one divisor, was 0 at once; from the left each took twelve seconds. Found + /// by limitcheck at DEPTH=3, SEED=59; no issue was filed. + /// + [Trait("Area", "Calculus")] + public sealed class AProductWithAQuotientFactorTest + { + [Theory] + [InlineData("x * (ln(x) / ln(2 + x))", "0", ApproachFrom.Right)] + [InlineData("(ln(x) / ln(2 + x)) * x", "0", ApproachFrom.Right)] + [InlineData("x * log(2 + x, x)", "0", ApproachFrom.Right)] + [InlineData("x * log(2 + x, x)", "0", ApproachFrom.Left)] + [InlineData("sin(x) * (ln(x) / ln(3 - x))", "0", ApproachFrom.Right)] + [InlineData("x * (ln(-x) / ln(2 + x))", "0", ApproachFrom.Left)] + public void IsZero(string expr, string at, ApproachFrom side) + { + var asked = Task.Run(() => expr.ToEntity().Limit("x", at, side)); + Assert.True(asked.Wait(TimeSpan.FromSeconds(20)), $"the limit of {expr} at {at} from the {side} did not finish"); + var limit = asked.Result; + Assert.DoesNotContain(limit.Nodes, node => node is Entity.Limitf); + Assert.Equal(Entity.Number.Integer.Zero, limit.Simplify()); + } + } +} From 5a25201dbb58dc728c0ee5be43609011990bad23 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sat, 7 Nov 2026 22:12:27 +0000 Subject: [PATCH 2/2] Record the products read over a quotient's divisor in BREAKING-CHANGES Co-Authored-By: Claude Opus 5.5 --- BREAKING-CHANGES.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index 6a6271474..fee09e766 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -42,6 +42,21 @@ A not-equal written `<>` is read as `not (a = b)`, and printed that way. ## Unreleased — since 2.6.0 +### A product with a quotient for a factor is read over that quotient's divisor in a one-sided limit + +**Silent: a one-sided limit of 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.** Read as a product nothing settled the form. Some of these +were left unevaluated, and some took half a minute through l'Hôpital's rule for what the same expression over one +divisor answers at once. A two-sided limit is not changed. Found by limitcheck; no issue was filed. + +| Input | Was (2.6.0) | Now | +|---|---|---| +| `"sin(ln(x) * x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sin(ln(x) * x), x, 0)` | `0` | +| `"floor(x * log(pi, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(floor(x * log(pi, x)), x, 0)` | `-1` | +| `"sgn(sin(x) * log(pi, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sgn(sin(x) * log(pi, x)), x, 0)` | `-1` | +| `"arcsin(-x * log(-1, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(arcsin(-x * log(-1, x)), x, 0)` | `0` | +| `"x * log(2 + x, x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `0` after 27 s | `0` in 0.25 s | + ### A limit at the jump of a step function is not answered by substitution **Silent: a limit of an expression built on `floor`, `ceil`, `round` or `sgn`, where the step's argument arrives on one