Skip to content

Commit 567890f

Browse files
Read a real power of a vanishing function in a limit by its order (#2397)
Read a real power of a vanishing function in a limit by its order A power g^a to an exponent that is not an integer, of a g tending to 0 or +oo, had no reading against a logarithm unless g was x itself: x^pi ln(x) at 0 from the right was 0, while sin(x)^pi ln(x), and even (2x)^pi ln(x), were left unevaluated, and ln(x) / (2x)^(-pi) took fifteen seconds to be. As a factor of the product or quotient the expression is, g^a is x^(k a) times (g / x^k)^a, where k, the limit of x g' / g, is the power of x that g behaves like. The second part tends to a positive number, which is taken out of the limit, and what is left is a power of x against the rest. Only a factor is rewritten: in a sum, the part taken out is the whole of the answer. A base tending to -oo is not read: its real power is complex, and asking for its order took a decline that master gives in 0.3 s to 17.6 s. Found by limitcheck; no issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 47b6600 commit 567890f

3 files changed

Lines changed: 137 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,28 @@ 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 real power in a limit is read by its order
111+
112+
**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
113+
as `x^(k a)` times `(g / x^k)^a`, where `k` is the power of `x` that `g` behaves like.** The second part tends to a
114+
positive number and is taken out of the limit, so the power left is one of `x` itself, which the other readings already
115+
answer. A non-integer power of anything but `x` was not read at all, so even `(2x)^pi ln(x)` at 0 was left unevaluated,
116+
and `ln(x) / (2x)^(-pi)` took 15 seconds to be. Only a factor of a product or a quotient is read this way, so a power
117+
inside a sum is left alone, and a base tending to -oo, whose real power is complex, is not read either. Found by
118+
limitcheck; no issue was filed.
119+
120+
| Input | Was (2.6.0) | Now |
121+
|---|---|---|
122+
| `"sin(x)^pi * ln(x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sin(x) ^ pi * ln(x), x, 0)` | `0` |
123+
| `"(2x)^pi * ln(x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright((2 * x) ^ pi * ln(x), x, 0)` | `0` |
124+
| `"sqrt(sin(x)) * ln(x)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sqrt(sin(x)) * ln(x), x, 0)` | `0` |
125+
| `"ln(x) / (2x)^(-pi)".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(ln(x) / (2 * x) ^ (-pi), x, 0)` | `0` |
126+
| `"sin(sin(x)^pi * ln(x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sin(sin(x) ^ pi * ln(x)), x, 0)` | `0` |
127+
| `"sin(x)^pi / x^pi".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(sin(x) ^ pi / x ^ pi, x, 0)` | `1` |
128+
| `"(x^2 + 1)^(1/pi) / x^(2/pi)".ToEntity().Limit("x", "+oo")` | `limit((x ^ 2 + 1) ^ (1 / pi) / x ^ (2 / pi), x, +oo)` | `1` |
129+
| `"sqrt(arctan(1)) / (1/2 / x)^sinh(pi)".ToEntity().Limit("x", "+oo")` | `limit(sqrt(arctan(1)) / (1/2 / x) ^ ((e ^ pi - e ^ (-pi)) / 2), x, +oo)` | `+oo` |
130+
| `"x / (1/2) / (x + 1)^pi".ToEntity().Limit("x", -1, ApproachFrom.Right)` | `limitright(x / (1/2) / (x + 1) ^ pi, x, -1)` | `-oo` |
131+
110132
### The sign of a limit is read through a change of variable
111133

112134
**Silent: in a limit, where the variable is only inside one part `u` of an expression `h(u)`, the expression's sign near

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,10 @@ static Entity Times(Entity taken, Entity limit)
20302030
&& Settled(extracted.ComputeLimitDivideEtImpera(x, toInfinity, ApproachFrom.Left)) is { } byGrowth)
20312031
return byGrowth;
20322032

2033+
if (FactorPowersByTheirOrder(simplified, x) is var (byOrder, coefficient)
2034+
&& Settled(ComputeLimit(byOrder, x, toInfinity)) is { } byItsOrder)
2035+
return (coefficient * byItsOrder).InnerSimplified;
2036+
20332037
// A factorial's logarithm has no reading anywhere else -- every route out of
20342038
// ln(f) differentiates f, and a factorial's derivative wants the digamma
20352039
// function. SolveAsIndeterminatePower reaches the ones sitting under a
@@ -2110,6 +2114,56 @@ Entity RewriteRoot(Entity node)
21102114
}
21112115
}
21122116

2117+
/// <summary>
2118+
/// The expression with every factor <c>g^a</c> of it -- a factor of the product or the quotient it is -- to a
2119+
/// constant exponent that is not an integer, of a <c>g</c> tending to 0 or an infinity, replaced by
2120+
/// <c>x^(k a)</c>, and the product of the limits <c>L^a</c> of what was taken out; or <see langword="null"/> if
2121+
/// there is no such factor. <c>k</c> is the limit of <c>x g' / g</c>, the power of x that <c>g</c> behaves like,
2122+
/// taken where it is rational, and <c>L</c> is the limit of <c>g / x^k</c>, taken where it is a positive number.
2123+
/// <c>sin(x)^pi ln(x)</c> at 0 from the right is <c>sin(1/x)^pi ln(1/x)</c> here, and nothing read a power of
2124+
/// <c>sin(1/x)</c> alongside a logarithm, while it is <c>(x sin(1/x))^pi</c>, which tends to 1, times
2125+
/// <c>x^(-pi) ln(1/x)</c>, which tends to 0.
2126+
/// </summary>
2127+
/// <remarks>
2128+
/// A factor tending to a positive number can be taken out of a limit, and <c>(uv)^a = u^a v^a</c> needs <c>u</c>
2129+
/// positive, which <c>x^k</c> is on the way to +oo, the only direction this is used in. Only a factor: inside a
2130+
/// sum, <c>sin(x)^pi - x^pi</c>, the part taken out is the whole of the answer.
2131+
/// </remarks>
2132+
private static (Entity Rewritten, Entity Coefficient)? FactorPowersByTheirOrder(Entity expr, Variable x)
2133+
{
2134+
Entity coefficient = Integer.One;
2135+
var rewritten = Factor(expr, inDivisor: false);
2136+
return rewritten == expr ? null : (rewritten, coefficient);
2137+
2138+
Entity Factor(Entity node, bool inDivisor)
2139+
{
2140+
switch (node)
2141+
{
2142+
case Mulf(var left, var right):
2143+
return Factor(left, inDivisor) * Factor(right, inDivisor);
2144+
case Divf(var dividend, var divisor):
2145+
return Factor(dividend, inDivisor) / Factor(divisor, !inDivisor);
2146+
case Powf(var @base, var exponent) when @base.ContainsNode(x) && @base != x
2147+
&& !exponent.ContainsNode(x) && exponent.Evaled is Real { IsFinite: true } and not Integer:
2148+
var baseLimit = ComputeLimit(@base, x, Real.PositiveInfinity);
2149+
// Only a base tending to 0 or to +oo: a real power of a negative base is
2150+
// complex, and the limits below are too dear to ask for one.
2151+
if (InfiniteSign(baseLimit) != 1 && (baseLimit is null || EvalAssumingContinuous(baseLimit) is not Complex { IsZero: true }))
2152+
return node;
2153+
if (ComputeLimit(x * @base.Differentiate(x) / @base, x, Real.PositiveInfinity) is not { } orderLimit
2154+
|| EvalAssumingContinuous(orderLimit) is not Rational order || order == 0)
2155+
return node;
2156+
if (ComputeLimit(@base / MathS.Pow(x, order), x, Real.PositiveInfinity) is not { } limit
2157+
|| EvalAssumingContinuous(limit) is not Real { IsFinite: true, IsNegative: false } positive || positive == 0)
2158+
return node;
2159+
coefficient = inDivisor ? coefficient / MathS.Pow(limit, exponent) : coefficient * MathS.Pow(limit, exponent);
2160+
return MathS.Pow(x, order * exponent);
2161+
default:
2162+
return node;
2163+
}
2164+
}
2165+
}
2166+
21132167
/// <summary>
21142168
/// How many times a single limit may be broken down as a difference of two divergent
21152169
/// parts. The conjugate below turns one difference into another, and every part of it
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
/// A power g^a to an exponent that is not an integer, of a g tending to 0, had no reading against a logarithm unless
16+
/// g was x itself: x^pi ln(x) at 0 from the right was 0 and sin(x)^pi ln(x), and even (2x)^pi ln(x), were left
17+
/// unevaluated, while ln(x) / (2x)^(-pi) took fifteen seconds to be. As a factor, g^a is x^(k a) times
18+
/// (g / x^k)^a, where k is the power of x that g behaves like, and the second part tends to a positive number that
19+
/// can be taken out of the limit. Found by limitcheck; no issue was filed.
20+
/// </summary>
21+
[Trait("Area", "Calculus")]
22+
public sealed class APowerIsReadByItsOrderTest
23+
{
24+
[Theory]
25+
[InlineData("sin(x)^pi * ln(x)", "0")]
26+
[InlineData("(2x)^pi * ln(x)", "0")]
27+
[InlineData("sqrt(sin(x)) * ln(x)", "0")]
28+
[InlineData("tan(x)^pi * ln(x)", "0")]
29+
[InlineData("(1 - cos(x))^pi * ln(x)", "0")]
30+
[InlineData("(x + x^2)^pi * ln(x)", "0")]
31+
[InlineData("ln(x) / (2x)^(-pi)", "0")]
32+
[InlineData("sin(sin(x)^pi * ln(x))", "0")]
33+
[InlineData("sin(x)^pi / x^pi", "1")]
34+
public void AtZeroFromTheRight(string input, string expected)
35+
=> Assert.Equal(expected.ToEntity(), input.ToEntity().Limit("x", 0, ApproachFrom.Right));
36+
37+
[Fact]
38+
public void AtAnInfinity()
39+
=> Assert.Equal("1".ToEntity(), "(x^2 + 1)^(1/pi) / x^(2/pi)".ToEntity().Limit("x", "+oo", ApproachFrom.BothSides));
40+
41+
// Only a factor is taken out: in a sum the part taken out is the whole of the answer.
42+
[Fact]
43+
public void APowerInASumIsLeftAlone()
44+
=> Assert.Equal("0".ToEntity(), "sin(x)^pi - x^pi".ToEntity().Limit("x", 0, ApproachFrom.Right));
45+
46+
[Fact]
47+
public void APowerOfAGrowingBaseIsInTheDivisor()
48+
{
49+
Assert.Equal("+oo".ToEntity(), "sqrt(arctan(1)) / (1/2 / x)^sinh(pi)".ToEntity().Limit("x", "+oo", ApproachFrom.BothSides));
50+
Assert.Equal("-oo".ToEntity(), "x / (1/2) / (x + 1)^pi".ToEntity().Limit("x", -1, ApproachFrom.Right));
51+
}
52+
53+
// A real power of a base tending to -oo is complex and stays unevaluated. It is not read by its order, which
54+
// took 6.8 s to decline the first of these and 17.6 s the second, where master declines both in 0.3 s.
55+
[Theory]
56+
[InlineData("log(x^pi, pi^2)^arctan(tan(2))")]
57+
[InlineData("log(x, 2)^(1 - pi) / (log(1/2, x) - pi)")]
58+
public void APowerOfANegativeBaseIsDeclined(string input)
59+
=> Assert.IsType<Entity.Limitf>(input.ToEntity().Limit("x", 1, ApproachFrom.Left));
60+
}
61+
}

0 commit comments

Comments
 (0)