Skip to content

Commit f17be26

Browse files
Read a product with a power for a factor by the exponent's limit in a limit (#2417)
* Read a product with a power for a factor by the exponent's limit in a limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 58de4fb commit f17be26

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ divisor answers at once. A two-sided limit is not changed. Found by limitcheck;
5757
| `"arcsin(-x * log(-1, x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(arcsin(-x * log(-1, x)), x, 0)` | `0` |
5858
| `"x * log(2 + x, x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `0` after 27 s | `0` in 0.25 s |
5959

60+
### A product with a power for a factor is read by the power's exponent's limit in a one-sided limit
61+
62+
**Silent: a one-sided limit of a product whose factors tend to 0 and to an infinity, one of them a power `u^v` whose
63+
exponent tends to a constant `c` other than 0, is read as `(other * u^c) * u^(v - c)`** wherever `u^(v - c)` tends to a
64+
finite real other than 0. The principal power splits that way for any `u`. `(tan(x) + 1)^(x^(x - 1))` at 0 from the
65+
right has the exponent `tan(x) * x^(x - 1)`, which is `tan(x) / x` times `x^x` and tends to 1, so the limit is `e`.
66+
l'Hôpital's rule differentiated `x^(x - 1)` instead, and did not finish. A two-sided limit is not changed. Found by
67+
limitcheck; no issue was filed.
68+
69+
| Input | Was (2.6.0) | Now |
70+
|---|---|---|
71+
| `"(tan(x) + 1)^(x^(x - 1))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright((tan(x) + 1) ^ x ^ (x - 1), x, 0)` | `e` |
72+
| `"tan(x) * x^(x - 1)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `1` after 11 s | `1` in 0.21 s |
73+
6074
### A derivative keeps an exponent that is not rational exact
6175

6276
**Silent: the power rule writes a constant exponent that is not rational as it is, where it wrote its decimal

‎Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ partial record Mulf
116116
&& AsTheWholeLimit(distributed, x, dist, side) is { } termByTerm
117117
&& termByTerm.Evaled != MathS.NaN)
118118
return termByTerm;
119+
// So, with a power u^v for one factor whose exponent tends to a constant c other than 0, is the
120+
// product read as (other * u^c) * u^(v - c), where u^(v - c) has a finite limit other than 0. That
121+
// holds for the principal power, e^(v ln u) being e^(c ln u) e^((v - c) ln u). The exponent of
122+
// (tan(x) + 1)^(x^(x - 1)) at 0 from the right is (tan(x) + 1 - 1) * x^(x - 1), and l'Hopital's rule
123+
// differentiated x^(x - 1) for longer than any caller waits, where tan(x) / x tends to 1 and x^x to 1.
124+
if (side is not ApproachFrom.BothSides && !IsComparingSides
125+
&& multiplierLimit is { } zeroOrInfinity7 && multiplicandLimit is { } zeroOrInfinity8
126+
&& IsZeroTimesAnInfinity(zeroOrInfinity7, zeroOrInfinity8)
127+
&& (ByTheExponentsLimit(Multiplicand, Multiplier, x, dist, side) ?? ByTheExponentsLimit(Multiplier, Multiplicand, x, dist, side))
128+
is { } byTheExponentsLimit)
129+
return byTheExponentsLimit;
119130
var (mp, md) =
120131
(multiplierLimit, multiplicandLimit) switch
121132
{
@@ -266,6 +277,21 @@ private static bool IsAnIndeterminateQuotient(Entity dividend, Entity divisor)
266277
_ => false,
267278
};
268279

280+
/// <summary>
281+
/// The limit of <c>power * other</c> read as <c>(other * u^c) * u^(v - c)</c>, for a power <c>u^v</c> whose exponent
282+
/// tends to a constant <c>c</c> other than 0 and where <c>u^(v - c)</c> tends to a finite real other than 0.
283+
/// </summary>
284+
private static Entity? ByTheExponentsLimit(Entity power, Entity other, Variable x, Entity dist, ApproachFrom side)
285+
{
286+
if (power is not Powf(var @base, var exponent) || !exponent.ContainsNode(x)
287+
|| exponent.ComputeLimitDivideEtImpera(x, dist, side)?.Evaled is not Real { IsFinite: true, IsZero: false, IsNaN: false } constant
288+
|| MathS.Pow(@base, (exponent - constant).InnerSimplified).ComputeLimitDivideEtImpera(x, dist, side)?.Evaled
289+
is not Real { IsFinite: true, IsZero: false, IsNaN: false } rest
290+
|| AsTheWholeLimit(other * MathS.Pow(@base, constant), x, dist, side)?.Evaled is not Number { IsNaN: false } head)
291+
return null;
292+
return (head * rest).Evaled;
293+
}
294+
269295
/// <summary>Whether two factors' limits make a product 0 * oo.</summary>
270296
private static bool IsZeroTimesAnInfinity(Entity first, Entity second)
271297
=> (first.Evaled, second.Evaled) switch
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 System;
9+
using System.Threading.Tasks;
10+
using AngouriMath.Core;
11+
using AngouriMath.Extensions;
12+
using Xunit;
13+
14+
namespace AngouriMath.Tests.Calculus
15+
{
16+
/// <summary>
17+
/// A product tending to 0 * oo with a power u^v for a factor, v tending to a constant c other than 0, is read as
18+
/// (other * u^c) * u^(v - c). (tan(x) + 1)^(x^(x - 1)) at 0 from the right has the exponent tan(x) * x^(x - 1), which is
19+
/// tan(x) / x times x^x, and l'Hopital's rule differentiated x^(x - 1) for longer than any caller waits.
20+
/// Found by limitcheck; no issue was filed.
21+
/// </summary>
22+
[Trait("Area", "Calculus")]
23+
public sealed class APowerIsSplitAtItsExponentsLimitTest
24+
{
25+
[Theory]
26+
[InlineData("(tan(x) + 1)^(x^(x - 1))", "e")]
27+
[InlineData("tan(x) * x^(x - 1)", "1")]
28+
[InlineData("sin(x) * x^(x - 1)", "1")]
29+
[InlineData("x^2 * x^(x - 3)", "+oo")]
30+
[InlineData("ln(x) * x^(x + 1)", "0")]
31+
public void TheLimitFromTheRightIsAnswered(string input, string expected)
32+
{
33+
var limit = Task.Run(() => input.ToEntity().Limit("x", 0, ApproachFrom.Right));
34+
Assert.True(limit.Wait(TimeSpan.FromSeconds(30)), $"the limit of {input} did not finish");
35+
Assert.Equal(expected.ToEntity().Evaled, limit.Result.Evaled);
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)