Skip to content

Commit 3c2951c

Browse files
Read a grown derivatives' quotient's value at the point once expanded (#2391)
Record reading a grown derivatives' quotient expanded as a breaking change Read a grown derivatives' quotient's value at the point once expanded l'Hopital's rule declined a quotient that grew too much to differentiate again unless it had a value at the point. 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 none at 0 as written, since x^(-1/2) has none. So x ln(sqrt(x) cos(x)) and (sqrt(x) cos(x))^x at 0 from the right were left unevaluated, where x^(1/3) cos(x) in their place was answered. The value is now also read from the quotient expanded, which gathers the powers of x and is 0 there. Taking the grown quotient's limit with the rule suppressed answered the same rows but cost seconds a step: x^(tanh(x)^3) at 0 went from 2.5 s to 18 s, and one row from 1.7 s to over 30 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6a14757 commit 3c2951c

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ where the two sides disagree. `1/sin(x)^2` already answered +oo; `sin(x)^(-2)` d
277277
| `"(arcsin(x)^(-2))^2".ToEntity().Limit("x", 0)` | `NaN` | `+oo` |
278278
| `"sin(x)^(-1)".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `NaN` | `-oo` |
279279

280+
### A derivatives' quotient with no value as written is read expanded
281+
282+
**l'Hopital's rule reads the value at the point of a quotient that grew too much to differentiate again from the
283+
quotient expanded as well as as written.** The product rule makes `ln(sqrt(x) cos(x)) / (1 / x)`'s quotient
284+
`-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
285+
which expanded is `-x cos(x) sec(x) / 2 + x^2 sin(x) sec(x)`, 0 there. These were left unevaluated.
286+
287+
| Input | Was (2.6.0) | Now |
288+
|---|---|---|
289+
| `"(sqrt(x) cos(x))^x".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `1` |
290+
| `"x ln(sqrt(x) cos(x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |
291+
| `"ln(sqrt(x) cos(x)) / (1 / x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |
292+
280293
### A quotient whose divisor is 0 near the point has no limit there
281294

282295
**A limit of a quotient whose divisor is 0 all the way in is NaN, where it was a number.** `abs(x) - x` is

‎Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,8 +1910,16 @@ bool VanishesIdentically(Entity polynomial)
19101910
// log(x, 1/2) ^ (e^x - sgn(x)) at 0 from the right, whose descent reaches
19111911
// here at +oo with e^(1/x) taken out, took nine seconds where it took a half.
19121912
// At a finite point the bound is as it was, whose taking out it was set for.
1913+
// A value at the point is read expanded too, where powers of the variable
1914+
// that the product rule left apart are gathered: ln(sqrt(x) * cos(x)) / (1 / x)
1915+
// becomes -x^(3/2) * (x^(-1/2) * cos(x) / 2 - sqrt(x) * sin(x)) * sec(x), which
1916+
// has no value at 0 as written, since x^(-1/2) has none, and expanded is
1917+
// -x * cos(x) * sec(x) / 2 + x^2 * sin(x) * sec(x), which is 0 there. A limit of the grown
1918+
// quotient, even with the rule kept out of it, cost seconds per step.
19131919
if (GrewTooMuch(dest.IsFinite ? expr : numRest / denRest, applied))
1914-
return ItsValueAt(applied, x, dest) is { } value ? Times(taken, value) : null;
1920+
return ItsValueAt(applied, x, dest) is { } value ? Times(taken, value)
1921+
: dest.IsFinite && ItsValueAt(applied.Expand().InnerSimplified, x, dest) is { } expanded ? Times(taken, expanded)
1922+
: null;
19151923
lHopitalApplications++;
19161924
MultithreadingFunctional.ExitIfCancelled();
19171925
lHopitalChain!.Add(applied);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// Copyright (c) 2019-2026 Angouri.
3+
// AngouriMath is licensed under MIT.
4+
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
5+
// Website: https://am.angouri.org.
6+
//
7+
8+
using AngouriMath.Core;
9+
using Xunit;
10+
using static AngouriMath.Entity;
11+
12+
namespace AngouriMath.Tests.Calculus
13+
{
14+
/// <summary>
15+
/// A derivatives' quotient that grew too much to differentiate again is still read at the point once expanded. For
16+
/// 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),
17+
/// which has no value at 0 and tends to 0 there, so the limit was left unevaluated, and (sqrt(x) cos(x))^x with
18+
/// it, while x^(1/3) cos(x) in its place was answered. Found by probing; no issue was filed.
19+
/// </summary>
20+
[Trait("Area", "Calculus")]
21+
public sealed class AGrownQuotientIsStillReadTest
22+
{
23+
[Theory]
24+
[InlineData("ln(sqrt(x) * cos(x)) / (1 / x)", "0")]
25+
[InlineData("x * ln(sqrt(x) * cos(x))", "0")]
26+
[InlineData("(sqrt(x) * cos(x))^x", "1")]
27+
public void AtZeroFromTheRight(string input, string expected)
28+
=> Assert.Equal(MathS.FromString(expected), MathS.FromString(input).Limit("x", 0, ApproachFrom.Right));
29+
30+
// Left of 0 the base is imaginary; that side is not decided here, and the two-sided limit stays NaN as before.
31+
[Fact]
32+
public void TwoSidedIsUnchanged()
33+
=> Assert.Equal(MathS.NaN, MathS.FromString("(sqrt(x) * cos(x))^x").Limit("x", 0));
34+
}
35+
}

0 commit comments

Comments
 (0)