Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
38 changes: 38 additions & 0 deletions Sources/Tests/UnitTests/Calculus/AVanishingFactorTimesASumTest.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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 <c>x * (ln(-tanh(x)) + 1)</c> at 0 from the left through
/// four and a half seconds of nested limits, where <c>x ln(-tanh(x)) + x</c> is 0 at once; and
/// <c>(tanh(x)^3)^exp(1/x)</c> came to the same product. Found in the limitcheck A/B of the
/// logarithm-of-a-power change; no issue was filed.
/// </summary>
[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);
}
}
}
Loading