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
13 changes: 13 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ where the two sides disagree. `1/sin(x)^2` already answered +oo; `sin(x)^(-2)` d
| `"(arcsin(x)^(-2))^2".ToEntity().Limit("x", 0)` | `NaN` | `+oo` |
| `"sin(x)^(-1)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `NaN` | `-oo` |

### A derivatives' quotient with no value as written is read expanded

**l'Hopital's rule reads the value at the point of a quotient that grew too much to differentiate again from the
quotient expanded as well as as written.** The product rule makes `ln(sqrt(x) cos(x)) / (1 / x)`'s quotient
`-x^(3/2) (x^(-1/2) cos(x) / 2 - sqrt(x) sin(x)) sec(x)`, which has no value at 0 since `x^(-1/2)` has none, and
which expanded is `-x cos(x) sec(x) / 2 + x^2 sin(x) sec(x)`, 0 there. These were left unevaluated.

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"(sqrt(x) cos(x))^x".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `1` |
| `"x ln(sqrt(x) cos(x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |
| `"ln(sqrt(x) cos(x)) / (1 / x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |

### A quotient whose divisor is 0 near the point has no limit there

**A limit of a quotient whose divisor is 0 all the way in is NaN, where it was a number.** `abs(x) - x` is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,16 @@ bool VanishesIdentically(Entity polynomial)
// log(x, 1/2) ^ (e^x - sgn(x)) at 0 from the right, whose descent reaches
// here at +oo with e^(1/x) taken out, took nine seconds where it took a half.
// At a finite point the bound is as it was, whose taking out it was set for.
// A value at the point is read expanded too, where powers of the variable
// that the product rule left apart are gathered: ln(sqrt(x) * cos(x)) / (1 / x)
// becomes -x^(3/2) * (x^(-1/2) * cos(x) / 2 - sqrt(x) * sin(x)) * sec(x), which
// has no value at 0 as written, since x^(-1/2) has none, and expanded is
// -x * cos(x) * sec(x) / 2 + x^2 * sin(x) * sec(x), which is 0 there. A limit of the grown
// quotient, even with the rule kept out of it, cost seconds per step.
if (GrewTooMuch(dest.IsFinite ? expr : numRest / denRest, applied))
return ItsValueAt(applied, x, dest) is { } value ? Times(taken, value) : null;
return ItsValueAt(applied, x, dest) is { } value ? Times(taken, value)
: dest.IsFinite && ItsValueAt(applied.Expand().InnerSimplified, x, dest) is { } expanded ? Times(taken, expanded)
: null;
lHopitalApplications++;
MultithreadingFunctional.ExitIfCancelled();
lHopitalChain!.Add(applied);
Expand Down
35 changes: 35 additions & 0 deletions Sources/Tests/UnitTests/Calculus/AGrownQuotientIsStillReadTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 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 Xunit;
using static AngouriMath.Entity;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// A derivatives' quotient that grew too much to differentiate again is still read at the point once expanded. For
/// ln(sqrt(x) cos(x)) / (1 / x) the product rule gives -x^(3/2) (x^(-1/2) cos(x) / 2 - sqrt(x) sin(x)) sec(x),
/// which has no value at 0 and tends to 0 there, so the limit was left unevaluated, and (sqrt(x) cos(x))^x with
/// it, while x^(1/3) cos(x) in its place was answered. Found by probing; no issue was filed.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class AGrownQuotientIsStillReadTest
{
[Theory]
[InlineData("ln(sqrt(x) * cos(x)) / (1 / x)", "0")]
[InlineData("x * ln(sqrt(x) * cos(x))", "0")]
[InlineData("(sqrt(x) * cos(x))^x", "1")]
public void AtZeroFromTheRight(string input, string expected)
=> Assert.Equal(MathS.FromString(expected), MathS.FromString(input).Limit("x", 0, ApproachFrom.Right));

// Left of 0 the base is imaginary; that side is not decided here, and the two-sided limit stays NaN as before.
[Fact]
public void TwoSidedIsUnchanged()
=> Assert.Equal(MathS.NaN, MathS.FromString("(sqrt(x) * cos(x))^x").Limit("x", 0));
}
}
Loading