From b8bd485fb7988898c04bd4b39f5802ae60e80322 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 8 Nov 2026 21:09:54 +0000 Subject: [PATCH] Read a limit of a quotient over a quotient as a quotient of products The descent read a / (b / c) as written. x^(-pi) / (ln(2) / ln(x)) at +oo is then 0/0, and l'Hopital's rule makes each step another 0 * oo with a higher power of ln(x), so it was left unevaluated where x^(-pi) ln(x) / ln(2), the same function, is 0. log(x, 2) is ln(2) / ln(x), so x^(-pi) / log(x, 2) was left unevaluated too. Where b is a constant, the quotient is now read first as a c / b, which it equals wherever it has a value, and that reading is kept only where it gives one. x ln(x) at 0 comes back from the descent as 0 * (-oo), and taking that as the answer made x / log(x, 2) from both sides of 0 NaN where it is 0; there the quotient is read as written, as before. Over a b that is not constant, x^x / (x / x) read as x^x x / x took twenty times as long. Found by limitcheck; no issue was filed. Co-Authored-By: Claude Opus 5.5 --- BREAKING-CHANGES.md | 19 +++++++++ .../Limits/Solvers/Limit.Classes.cs | 10 +++++ .../Calculus/AQuotientOverAQuotientTest.cs | 42 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 Sources/Tests/UnitTests/Calculus/AQuotientOverAQuotientTest.cs diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index af1091742..c60952e70 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -107,6 +107,25 @@ filed. | `"floor(log(x - 1, x))".ToEntity().Limit("x", 1, ApproachFrom.Right)` | `limitright(floor(log(x - 1, x)), x, 1)` | `-1` | | `"floor(x / log(x, x))".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(floor(x / log(x, x)), x, 0)` | `-1` | +### A limit of a quotient over a quotient is read as a quotient of products + +**Silent: in a limit, `a / (b / c)` with `b` constant is read first as `a c / b`, and that reading is kept where it gives +a value.** Read as written, `x^(-pi) / (ln(2) / ln(x))` at +oo is 0/0, and each step of l'Hopital's rule gave another +0 * oo with a higher power of `ln(x)`, so it was left unevaluated. `log(x, 2)` is `ln(2) / ln(x)`, so any logarithm in +a divisor met this. Where the new reading gives no value -- `x ln(x)` at 0 is `0 * (-oo)` to it -- the quotient is read +as written, as before, and `x / log(x, 2)` at 0 is still 0. A two-sided limit that 2.6.0 answered and the master +before this change made NaN is answered again. Found by limitcheck; no issue was filed. + +| Input | Was (2.6.0) | Now | +|---|---|---| +| `"x^(-pi) / log(x, 2)".ToEntity().Limit("x", "+oo")` | `limit(x ^ (-pi) / log(x, 2), x, +oo)` | `0` | +| `"x^(-pi) / (ln(2) / ln(x))".ToEntity().Limit("x", "+oo")` | `limit(x ^ (-pi) / (ln(2) / ln(x)), x, +oo)` | `0` | +| `"(1/x)^pi / log(1/x, 2)".ToEntity().Limit("x", "+oo")` | `limit((1 / x) ^ pi / log(1 / x, 2), x, +oo)` | `0` | +| `"arcsin(pi + x) / (1/x)".ToEntity().Limit("x", 0)`, and from either side | `limit(arcsin(pi + x) / (1 / x), x, 0)` | `0` | +| `"tan(1/2) / log(x, -1) / tanh(sin(x))".ToEntity().Limit("x", 1, ApproachFrom.Left)` | `limitleft(tan(1/2) / log(x, -1) / ((e ^ (2 * sin(x)) - 1) / (e ^ (2 * sin(x)) + 1)), x, 1)` | `0` | +| `"tan(1/2) / log(x, -1) / tanh(sin(x))".ToEntity().Limit("x", 1)` | `NaN` | `0` | +| `"tanh(exp(pi)) / log(log(-1, x), 2)".ToEntity().Limit("x", -1)` | `0`, and `NaN` on master before this change | `0` | + ### A logarithm of a power is read through the logarithm of its base in a limit **Silent: in a limit, the logarithm of a power to a constant real exponent, `log(f^c)`, is read as `c log(f)`, or as diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs index 873c13029..ecb329a4e 100644 --- a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs +++ b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs @@ -149,6 +149,16 @@ partial record Divf { internal override Entity? ComputeLimitDivideEtImpera(Variable x, Entity dist, ApproachFrom side) { + // Over a quotient, as a quotient of products: a / (b / c) is a c / b wherever it has a value. Read as written, + // x^(-pi) / (ln(2) / ln(x)) at +oo is 0/0, and l'Hopital's rule makes each step of it another 0 * oo with a + // higher power of ln(x), so it was left unevaluated where x^(-pi) ln(x) / ln(2) is 0 at once. Only a value is + // taken from it. x ln(x) at 0 comes back as 0 * (-oo), which is no answer, and from both sides that was read + // as NaN, where x / log(x, 2) read as written is 0. And only over a constant: x^x / (x / x) as a product is + // x^x x / x, which took twenty times as long and answered from both sides of 0 where x^x itself is NaN. + if (Divisor is Divf(var over, var under) && under.ContainsNode(x) && !over.ContainsNode(x) + && New(Dividend * under, over).ComputeLimitDivideEtImpera(x, dist, side) is { } asProducts + && !asProducts.ContainsNode(x) && asProducts.Evaled != MathS.NaN) + return asProducts; // A form with no value -- 0 * +oo / 0, which is what -x / (sqrt(1 - x^2) * arcsin(x)) at 0 // from the right comes back as -- is the claim that there is no limit, and the parts may // say otherwise. It is kept for the end, where it was answered before, and the parts are diff --git a/Sources/Tests/UnitTests/Calculus/AQuotientOverAQuotientTest.cs b/Sources/Tests/UnitTests/Calculus/AQuotientOverAQuotientTest.cs new file mode 100644 index 000000000..dd9b72882 --- /dev/null +++ b/Sources/Tests/UnitTests/Calculus/AQuotientOverAQuotientTest.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 AngouriMath.Core; +using AngouriMath.Extensions; +using Xunit; + +namespace AngouriMath.Tests.Calculus +{ + /// + /// A quotient whose divisor is a quotient was read as written. x^(-pi) / (ln(2) / ln(x)) at +oo is then 0/0, and + /// l'Hopital's rule makes each step of it another 0 * oo with a higher power of ln(x), so it was left unevaluated + /// where x^(-pi) ln(x) / ln(2), the same function, is 0. log(x, 2) is ln(2) / ln(x), so x^(-pi) / log(x, 2) was + /// left unevaluated too. The reading as a quotient of products is taken only where it gives a value: x ln(x) at 0 + /// is 0 * (-oo) to it, and x / log(x, 2) from both sides of 0 stays 0. Found by limitcheck; no issue was filed. + /// + [Trait("Area", "Calculus")] + public sealed class AQuotientOverAQuotientTest + { + [Theory] + [InlineData("x^(-pi) / (ln(2) / ln(x))", "+oo", ApproachFrom.BothSides, "0")] + [InlineData("x^(-pi) / log(x, 2)", "+oo", ApproachFrom.BothSides, "0")] + [InlineData("(1/x)^pi / log(1/x, 2)", "+oo", ApproachFrom.BothSides, "0")] + [InlineData("arcsin(pi + x) / (1 / x)", "0", ApproachFrom.BothSides, "0")] + [InlineData("tan(1/2) / log(x, -1) / tanh(sin(x))", "1", ApproachFrom.Left, "0")] + [InlineData("tanh(exp(pi)) / log(log(-1, x), 2)", "-1", ApproachFrom.BothSides, "0")] + // Read as written, and not as x ln(x) / ln(2), whose limit from both sides was NaN. + [InlineData("x / log(x, 2)", "0", ApproachFrom.BothSides, "0")] + [InlineData("x ^ log(pi + 1, x - 1)", "1", ApproachFrom.BothSides, "1")] + public void IsReadAsAQuotientOfProducts(string input, string destination, ApproachFrom side, string expected) + => Assert.Equal(expected.ToEntity(), input.ToEntity().Limit("x", destination, side)); + + // The divisor's own divisor vanishing does not make the quotient vanish: x / (1 / x) is x^2, +oo at +oo. + [Fact] + public void TheInnerDivisorIsAFactorOfTheDividend() + => Assert.Equal("+oo".ToEntity(), "x / (1 / x)".ToEntity().Limit("x", "+oo", ApproachFrom.BothSides)); + } +}