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
19 changes: 19 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions Sources/Tests/UnitTests/Calculus/AQuotientOverAQuotientTest.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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.
/// </summary>
[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));
}
}
Loading