Skip to content

Commit 69aa9bd

Browse files
Read a power of a power of a positive base in a limit as one power (#2398)
Read a power of a power of a positive base in a limit as one power (g^a)^b, with a and b real constants, is g^(a b) wherever g is positive, and in a limit nothing read it so. Read as written, sqrt(x^3) / x at 0 from the right came out 0 only after four seconds of l'Hopital's rule, each step another root over a power, and floor(sqrt(x^3)) took six, asking it for the sign of sqrt(x^3). The power is now merged in front of the descent, beside the logarithm of a power, where g is positive near the point on each side approached. Where g is negative the two differ -- sqrt(x^3) is i |x|^(3/2) for x < 0 and x^(3/2) is -i |x|^(3/2) -- so from the left and from both sides nothing changes. An integer outer exponent is left to the normalisation. Found by limitcheck; no issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 567890f commit 69aa9bd

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ filed.
107107
| `"floor(log(x - 1, x))".ToEntity().Limit("x", 1, ApproachFrom.Right)` | `limitright(floor(log(x - 1, x)), x, 1)` | `-1` |
108108
| `"floor(x / log(x, x))".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(floor(x / log(x, x)), x, 0)` | `-1` |
109109

110+
### A power of a power of a positive base is one power in a limit
111+
112+
**Silent: in a limit, `(g^a)^b` with `a` and `b` real constants, `b` not an integer, is read as `g^(a b)` where `g` is
113+
positive near the point on each side approached.** The two are equal for a positive `g` and not for a negative one --
114+
`sqrt(x^3)` is `i |x|^(3/2)` for `x < 0`, where `x^(3/2)` is `-i |x|^(3/2)` -- so a limit from the left, or from both
115+
sides, of such a root is read as before. Read as written, `sqrt(x^3) / x` at 0 from the right was 0 only after 4
116+
seconds, and `floor(sqrt(x^3))` after 6; each now takes under 0.2 s. One limit 2.6.0 left unevaluated is answered.
117+
Found by limitcheck; no issue was filed.
118+
119+
| Input | Was (2.6.0) | Now |
120+
|---|---|---|
121+
| `"sinh(arctan(x))^sqrt(x * x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(((e ^ arctan(x) - e ^ (-arctan(x))) / 2) ^ sqrt(x * x), x, 0)` | `1` |
122+
110123
### A real power in a limit is read by its order
111124

112125
**Silent: in a limit, a factor `g^a` with `a` a constant that is not an integer, and `g` tending to 0 or to +oo, is read

‎Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ private static Entity LogarithmOfAPower(Entity node, Variable x, Entity dest, Ap
342342
};
343343
}
344344

345+
/// <summary>
346+
/// A power of a power to constant real exponents, (g^a)^b, as g^(a b) where g is positive near the point on each
347+
/// side approached.
348+
/// </summary>
349+
/// <remarks>
350+
/// For g positive and a, b real, g^a is positive and (g^a)^b is g^(a b). Where g is negative it is not:
351+
/// sqrt(x^3) is i |x|^(3/2) for x &lt; 0, and x^(3/2) is -i |x|^(3/2). Read as written, sqrt(x^3) / x at 0 from the
352+
/// right was 0 only after four seconds of l'Hopital's rule, each step another root over a power, where x^(3/2) / x
353+
/// is sqrt(x) at once; floor(sqrt(x^3)) and sgn(sqrt(x^3)) asked it for the sign of sqrt(x^3). An integer outer
354+
/// exponent is left to the normalisation, which takes (g^a)^n apart whatever the sign of g. Found by limitcheck;
355+
/// no issue was filed.
356+
/// </remarks>
357+
private static Entity PowerOfAPower(Entity node, Variable x, Entity dest, ApproachFrom side)
358+
=> node is Powf(Powf(var @base, var inner), var outer)
359+
&& @base.ContainsNode(x) && !inner.ContainsNode(x) && !outer.ContainsNode(x)
360+
&& inner.Evaled is Real { IsFinite: true } && outer.Evaled is Real { IsFinite: true } and not Integer
361+
&& SignOnEachSide(@base, x, dest, side) is 1
362+
? MathS.Pow(@base, (inner * outer).InnerSimplified)
363+
: node;
364+
345365
/// <summary>
346366
/// A logarithm to a base other than e as a quotient of natural logarithms.
347367
/// </summary>
@@ -492,6 +512,7 @@ node is Derivativef(var expression, Variable variable, var iterations) && iterat
492512

493513
expr = expr.Replace(ExpandLogarithm);
494514
expr = expr.Replace(node => LogarithmOfAPower(node, x, dest, side));
515+
expr = expr.Replace(node => PowerOfAPower(node, x, dest, side));
495516

496517
// In front of both paths, not only the two-sided one. Each of these is guarded on
497518
// a two-sided limit, and a two-sided limit that exists is also the limit from
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 AngouriMath.Extensions;
10+
using Xunit;
11+
12+
namespace AngouriMath.Tests.Calculus
13+
{
14+
/// <summary>
15+
/// In a limit, (g^a)^b with a and b real constants is g^(a b) where g is positive near the point. Read as written,
16+
/// sqrt(x^3) / x at 0 from the right was 0 only after four seconds of l'Hopital's rule, and floor(sqrt(x^3)) took six,
17+
/// asking it for the sign of sqrt(x^3). Where g is negative the two differ, so from the left and from both sides
18+
/// nothing changes. Found by limitcheck; no issue was filed.
19+
/// </summary>
20+
[Trait("Area", "Calculus")]
21+
public sealed class APowerOfAPowerIsOnePowerTest
22+
{
23+
[Theory]
24+
[InlineData("sqrt(x^3) / x", "0")]
25+
[InlineData("floor(sqrt(x^3))", "0")]
26+
[InlineData("sgn(sqrt(x^3))", "1")]
27+
[InlineData("sgn(sqrt(x^5))", "1")]
28+
[InlineData("sqrt(x^3) / x^(3/2)", "1")]
29+
public void AtZeroFromTheRight(string input, string expected)
30+
=> Assert.Equal(expected.ToEntity(), input.ToEntity().Limit("x", 0, ApproachFrom.Right));
31+
32+
[Fact]
33+
public void BothSidesOfAQuotientAgree()
34+
=> Assert.Equal("0".ToEntity(), "sqrt(x^3) / x".ToEntity().Limit("x", 0, ApproachFrom.BothSides));
35+
36+
// Left of 0, x^3 is negative and sqrt(x^3) is imaginary: floor of it has no limit to give.
37+
[Theory]
38+
[InlineData(ApproachFrom.Left)]
39+
[InlineData(ApproachFrom.BothSides)]
40+
public void ANegativeBaseIsLeftAlone(ApproachFrom side)
41+
=> Assert.IsType<Entity.Limitf>("floor(sqrt(x^3))".ToEntity().Limit("x", 0, side));
42+
}
43+
}

0 commit comments

Comments
 (0)