diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index 30c7923c0..e65f813d7 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -123,6 +123,17 @@ limitcheck; no issue was filed. | `"1/2 * x ^ abs(x)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(1/2 * x ^ abs(x), x, 0)` | `1/2` | | `"(pi / x) ^ erf(x) * e ^ log(x, x)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft((pi / x) ^ erf(x) * e ^ log(x, x), x, 0)` | `e` | +### A logarithm of a part tending to 1 is read as the part less 1 in a limit + +**Silent: a factor `ln(u)` whose antilogarithm tends to 1 is read as `u - 1`, as `sin(f)` is read as `f` where `f` +tends to 0, and a limit left unevaluated through it is answered.** `ln(1 + v) / x` at 0 from the right, with +`v = ln(sin(x) / x) / ln(x)`, is `v / x`, which is 0. A term of a sum is not rewritten, and a logarithm of a power is +still read as a product. limitcheck over 42 seeds answers the same rows as before. + +| Input | Was (2.6.0) | Now | +|---|---|---| +| `"ln(1 + ln(sin(x) / x) / ln(x)) / x".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` | + ### A grown derivatives' quotient is read by its terms in a limit **Silent: where l'Hopital's rule turns away a derivatives' quotient for growing too much, a one-sided limit at a finite diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs index eb9b1b127..e45c169eb 100644 --- a/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs +++ b/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs @@ -32,6 +32,21 @@ private static Entity EquivalenceRules(Entity expr, Variable x, Entity dest, App => expr is (Sinf or Tanf or Arcsinf or Arctanf) && EvalAssumingContinuous(expr.DirectChildren[0].Limit(x, dest, side)) == 0 ? expr.DirectChildren[0] + // ln(u) is equivalent to u - 1 where u tends to 1, as sin(f) is to f where f tends to 0: ln(1 + v) / x + // at 0 from the right with v = ln(sin(x) / x) / ln(x) is v / x, which is 0, and was left unevaluated, + // its quotient 0/0 and l'Hopital's derivatives too large to take. A 1 written as a term is taken off + // rather than left as 1 + v - 1, which the descent reads as a sum. Not the logarithm of a power, which is + // read as a product, and cos(x)^ln(x) - 1 over x^2 ln(x) at 0 is not answered where + // ln(x) ln(cos(x)) over it is -1/2. + : expr is Logf(var @base, var antilogarithm) && @base == MathS.e && antilogarithm is not Powf && antilogarithm.ContainsNode(x) + && EvalAssumingContinuous(antilogarithm.Limit(x, dest, side)) == 1 + ? antilogarithm switch + { + Sumf(var one, var rest) when one == Integer.One => rest, + Sumf(var rest, var one) when one == Integer.One => rest, + Minusf(var one, var rest) when one == Integer.One => -rest, + _ => antilogarithm - 1 + } : expr; internal static Entity EvalAssumingContinuous(Entity expr) => expr.Evaled switch diff --git a/Sources/Tests/UnitTests/Calculus/ALogarithmOfOneIsItsAntilogarithmLessOneTest.cs b/Sources/Tests/UnitTests/Calculus/ALogarithmOfOneIsItsAntilogarithmLessOneTest.cs new file mode 100644 index 000000000..090b82f4e --- /dev/null +++ b/Sources/Tests/UnitTests/Calculus/ALogarithmOfOneIsItsAntilogarithmLessOneTest.cs @@ -0,0 +1,37 @@ +// +// 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 factor ln(u) whose antilogarithm tends to 1 is equivalent to u - 1, as sin(f) is to f where f tends to 0: + /// ln(1 + ln(sin(x) / x) / ln(x)) / x at 0 from the right is ln(sin(x) / x) / (x ln(x)), which is 0, and was left + /// unevaluated. A term of a sum is not rewritten, and neither is the logarithm of a power, which is read as a product. + /// Found by limitcheck; no issue was filed. + /// + [Trait("Area", "Calculus")] + public sealed class ALogarithmOfOneIsItsAntilogarithmLessOneTest + { + [Theory] + [InlineData("ln(1 + ln(sin(x) / x) / ln(x)) / x", "0")] + [InlineData("ln(1 + x / ln(x)) * ln(x) / x", "1")] + [InlineData("ln(cos(x) ^ ln(x)) / (x ^ 2 * ln(x))", "-1/2")] + public void TheLimitFromTheRightIsAnswered(string input, string expected) + => Assert.Equal(expected.ToEntity().Evaled, input.ToEntity().Limit("x", 0, ApproachFrom.Right).Evaled); + + [Theory] + [InlineData("(ln(1 + x) - x) / x ^ 2", "-1/2")] + [InlineData("ln(1 + x) * cot(x)", "1")] + [InlineData("ln(cos(x)) / sin(x) ^ 2", "-1/2")] + public void TheLimitFromBothSidesIsAnswered(string input, string expected) + => Assert.Equal(expected.ToEntity().Evaled, input.ToEntity().Limit("x", 0, ApproachFrom.BothSides).Evaled); + } +}