From ace5582ab6cf3224ff07c8f636e23cb5177d372b Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 8 Nov 2026 04:41:21 +0000 Subject: [PATCH 1/2] Take a vanishing factor times a sum term by term in a one-sided limit From one side, a product whose factors tend to 0 and to an infinity, one of them a sum or a difference, is now asked as the sum of the products term by term, its whole limit once. Read as a product, l'Hopital's rule took x * (ln(-tanh(x)) + 1) at 0 from the left through nested limits for 4.5 s, where x ln(-tanh(x)) + x is 0 at once. The same gates as the quotient regrouping beside it: one-sided, and not while the sides of a two-sided limit are compared. x * (ln(-tanh(x)) + 1) at 0-: 4.5 s -> 0.44 s. e^(1/x) * (3 ln(-tanh(x)) + 1) at 0-: 7.2 s -> 0.46 s. (tanh(x)^3)^exp(1/x) at 0-: 7.5 s -> 0.47 s, the row the logarithm-of-a-power change (#2385) slowed. Co-Authored-By: Claude Opus 5.5 --- .../Limits/Solvers/Limit.Classes.cs | 17 +++++++++ .../Calculus/AVanishingFactorTimesASumTest.cs | 38 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Sources/Tests/UnitTests/Calculus/AVanishingFactorTimesASumTest.cs diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs index db806c586..3e928830a 100644 --- a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs +++ b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs @@ -99,6 +99,23 @@ partial record Mulf && AsTheWholeLimit(regrouped, x, dist, side) is { } overOneDivisor && overOneDivisor.Evaled != MathS.NaN) return overOneDivisor; + // So, with a sum or a difference for one factor, is the product taken term by term: + // l'Hopital's rule took x * (ln(-tanh(x)) + 1) at 0 from the left through four and a + // half seconds of nested limits, where x ln(-tanh(x)) + x is 0 at once. + if (side is not ApproachFrom.BothSides && !IsComparingSides + && multiplierLimit is { } zeroOrInfinity3 && multiplicandLimit is { } zeroOrInfinity4 + && IsZeroTimesAnInfinity(zeroOrInfinity3, zeroOrInfinity4) + && (Multiplicand, Multiplier) switch + { + (Sumf(var augend, var addend), var other) => other * augend + other * addend, + (var other, Sumf(var augend, var addend)) => augend * other + addend * other, + (Minusf(var minuend, var subtrahend), var other) => other * minuend - other * subtrahend, + (var other, Minusf(var minuend, var subtrahend)) => minuend * other - subtrahend * other, + _ => null + } is { } distributed + && AsTheWholeLimit(distributed, x, dist, side) is { } termByTerm + && termByTerm.Evaled != MathS.NaN) + return termByTerm; var (mp, md) = (multiplierLimit, multiplicandLimit) switch { diff --git a/Sources/Tests/UnitTests/Calculus/AVanishingFactorTimesASumTest.cs b/Sources/Tests/UnitTests/Calculus/AVanishingFactorTimesASumTest.cs new file mode 100644 index 000000000..cbf0c4237 --- /dev/null +++ b/Sources/Tests/UnitTests/Calculus/AVanishingFactorTimesASumTest.cs @@ -0,0 +1,38 @@ +// +// 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 Xunit; + +namespace AngouriMath.Tests.Calculus +{ + /// + /// From one side, a factor tending to 0 times a sum tending to an infinity is asked term by term. + /// Read as a product, l'Hopital's rule took x * (ln(-tanh(x)) + 1) at 0 from the left through + /// four and a half seconds of nested limits, where x ln(-tanh(x)) + x is 0 at once; and + /// (tanh(x)^3)^exp(1/x) came to the same product. Found in the limitcheck A/B of the + /// logarithm-of-a-power change; no issue was filed. + /// + [Trait("Area", "Calculus")] + public sealed class AVanishingFactorTimesASumTest + { + [Theory] + [InlineData("x * (ln(-tanh(x)) + 1)", "0")] + [InlineData("x * (ln(-tanh(x)) - 1)", "0")] + [InlineData("e^(1/x) * (3 * ln(-tanh(x)) + 1)", "0")] + [InlineData("(tanh(x)^3)^exp(1/x)", "1")] + [InlineData("sin(x) * (ln(-tanh(x)) + 1/x)", "1")] + public void IsAnsweredFromTheLeft(string input, string expected) + { + var limit = Task.Run(() => MathS.FromString(input).Limit("x", 0, ApproachFrom.Left)); + Assert.True(limit.Wait(TimeSpan.FromSeconds(20)), $"{input} did not finish"); + Assert.Equal(MathS.FromString(expected), limit.Result); + } + } +} From 7958a64059739dd6f6c473011cb81cd3e393a4c6 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 8 Nov 2026 06:14:01 +0000 Subject: [PATCH 2/2] Record the term-by-term product's changed answers 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 da3d4bc1c..f3ce305dd 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -98,6 +98,21 @@ issue was filed. | `"log(x^pi, sgn(-1))^2".ToEntity().Limit("x", 1)` | `NaN` | `-oo` | | `"(tanh(x)^erf(2))^sin(x^3)".ToEntity().Limit("x", 0, ApproachFrom.Right)`, and from the left | `limitright((((e ^ (2 * x) - 1) / (e ^ (2 * x) + 1)) ^ erf(2)) ^ sin(x ^ 3), x, 0)` | `1` | +### A vanishing factor times a sum is taken term by term 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 sum or a difference, +is asked term by term.** Read as a product, l'Hôpital's rule went through nested limits for what the distributed form +answers at once, and some rows were left unevaluated. A limit at an infinity is approached from one side and is +included; a two-sided limit at a finite point is not changed. Found by limitcheck; no issue was filed. + +| Input | Was (2.6.0) | Now | +|---|---|---| +| `"log(pi, x)^sinh(x) * sin(1)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | did not finish in 30 s | `sin(1)` | +| `"log(pi, x)^sinh(x) * sin(1)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | did not finish in 30 s | `sin(1)` | +| `"sin(e^x * (x + 1/2))".ToEntity().Limit("x", "-oo")` | `limit(sin(e ^ x * (x + 1/2)), x, -oo)` | `0` | +| `"x * (ln(-tanh(x)) + 1)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `0` in 3.2 s | `0` in 0.44 s | +| `"sin(x) * (ln(-tanh(x)) + 1/x)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `1` in 3.7 s | `1` in 1.1 s | + ### An equation through a negative whole power is not answered with no roots **Silent: an empty answer becomes the roots.** Inverting `x^n = v` for a negative whole `n` multiplied by the roots