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 @@ -42,6 +42,21 @@ A not-equal written `<>` is read as `not (a = b)`, and printed that way.

## Unreleased — since 2.6.0

### A product with a quotient for a factor is read over that quotient's divisor 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 quotient, is asked
as that quotient with the other factor in its dividend.** Read as a product nothing settled the form. Some of these
were left unevaluated, and some took half a minute through l'Hôpital's rule for what the same expression over one
divisor answers at once. A two-sided limit is not changed. Found by limitcheck; no issue was filed.

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"sin(ln(x) * x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sin(ln(x) * x), x, 0)` | `0` |
| `"floor(x * log(pi, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(floor(x * log(pi, x)), x, 0)` | `-1` |
| `"sgn(sin(x) * log(pi, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sgn(sin(x) * log(pi, x)), x, 0)` | `-1` |
| `"arcsin(-x * log(-1, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(arcsin(-x * log(-1, x)), x, 0)` | `0` |
| `"x * log(2 + x, x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `0` after 27 s | `0` in 0.25 s |

### A limit at the jump of a step function is not answered by substitution

**Silent: a limit of an expression built on `floor`, `ceil`, `round` or `sgn`, where the step's argument arrives on one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ partial record Mulf
return byMultiplier;
if (AnInfinityTimesASign(Multiplicand, Multiplier, multiplierLimit, dividing: false, x, dist, side) is { } byMultiplicand)
return byMultiplicand;
// 0 * oo from one side, with a quotient for one factor, is asked as that quotient
// with the other factor in its dividend, its whole limit once. Read as a product,
// nothing settles the form, and the rewriting solvers took x * (ln(x) / ln(2 + x)) at
// 0 from the right through l'Hopital's rule for longer than any caller waits, where
// (x ln(x)) / ln(2 + x) is 0 at once. One-sided only, and not while the sides of a
// two-sided limit are compared: two-sided, x * ln(x) / ln(2 + x) at 0 is NaN, its
// left side being complex, and regrouped there the same product written with
// brackets came back 0.
if (side is not ApproachFrom.BothSides && !IsComparingSides
&& multiplierLimit is { } zeroOrInfinity1 && multiplicandLimit is { } zeroOrInfinity2
&& IsZeroTimesAnInfinity(zeroOrInfinity1, zeroOrInfinity2)
&& (Multiplicand, Multiplier) switch
{
(Divf(var dividend, var divisor), var other) => new Divf(other * dividend, divisor),
(var other, Divf(var dividend, var divisor)) => new Divf(dividend * other, divisor),
_ => null
} is { } regrouped
&& AsTheWholeLimit(regrouped, x, dist, side) is { } overOneDivisor
&& overOneDivisor.Evaled != MathS.NaN)
return overOneDivisor;
var (mp, md) =
(multiplierLimit, multiplicandLimit) switch
{
Expand Down Expand Up @@ -206,6 +226,15 @@ private static bool IsAnIndeterminateQuotient(Entity dividend, Entity divisor)
_ => false,
};

/// <summary>Whether two factors' limits make a product 0 * oo.</summary>
private static bool IsZeroTimesAnInfinity(Entity first, Entity second)
=> (first.Evaled, second.Evaled) switch
{
(Complex { IsZero: true }, Number { IsFinite: false, IsNaN: false }) => true,
(Number { IsFinite: false, IsNaN: false }, Complex { IsZero: true }) => true,
_ => false,
};

/// <summary>The quotient whose whole limit is being asked from inside the descent, so that no other is asked inside it.</summary>
[System.ThreadStatic] private static HashSet<Entity>? quotientsAskedWhole;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ bool PositiveOnBothSides(Entity node)
internal static bool MayReadAPowerThroughItsExponent(Entity power)
=> !comparingSides && !ReferenceEquals(power, descentRoot);

/// <summary>
/// Whether the descent is reading the two sides of a two-sided limit to compare them. A
/// side read there is not that side's question, and a product regrouped there would decide
/// a two-sided limit with a complex side that the comparison leaves undecided.
/// </summary>
internal static bool IsComparingSides => comparingSides;

/// <summary>
/// Whether <paramref name="expr"/> is the whole of the question whose descent is under
/// way. The path that began the descent asks the rest of the machinery of it once the
Expand Down
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 System;
using System.Threading.Tasks;
using AngouriMath.Core;
using AngouriMath.Extensions;
using Xunit;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// A product whose factors tend to 0 and to an infinity, one of them a quotient, from one side.
/// Read as a product nothing settled the form, and x * (ln(x) / ln(2 + x)) at 0 from the right
/// did not finish in thirty seconds, nor did x * log(2 + x, x), where x ln(x) / ln(2 + x), the
/// same thing over one divisor, was 0 at once; from the left each took twelve seconds. Found
/// by limitcheck at <c>DEPTH=3</c>, <c>SEED=59</c>; no issue was filed.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class AProductWithAQuotientFactorTest
{
[Theory]
[InlineData("x * (ln(x) / ln(2 + x))", "0", ApproachFrom.Right)]
[InlineData("(ln(x) / ln(2 + x)) * x", "0", ApproachFrom.Right)]
[InlineData("x * log(2 + x, x)", "0", ApproachFrom.Right)]
[InlineData("x * log(2 + x, x)", "0", ApproachFrom.Left)]
[InlineData("sin(x) * (ln(x) / ln(3 - x))", "0", ApproachFrom.Right)]
[InlineData("x * (ln(-x) / ln(2 + x))", "0", ApproachFrom.Left)]
public void IsZero(string expr, string at, ApproachFrom side)
{
var asked = Task.Run(() => expr.ToEntity().Limit("x", at, side));
Assert.True(asked.Wait(TimeSpan.FromSeconds(20)), $"the limit of {expr} at {at} from the {side} did not finish");
var limit = asked.Result;
Assert.DoesNotContain(limit.Nodes, node => node is Entity.Limitf);
Assert.Equal(Entity.Number.Integer.Zero, limit.Simplify());
}
}
}
Loading