Skip to content

Commit a3d11bf

Browse files
Read a power of a positive limit to a constant exponent by continuity in a limit (#2412)
* Read a power of a positive limit to a constant exponent by continuity in a limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c1321e0 commit a3d11bf

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,16 @@ partial record Powf
462462
{
463463
internal override Entity? ComputeLimitDivideEtImpera(Variable x, Entity dist, ApproachFrom side)
464464
{
465+
// A base tending to a positive number or to +oo, to a constant real exponent that is
466+
// not 0, is continuous there: the power tends to the base's limit to that exponent,
467+
// and nothing about the whole has to be read. Asking the whole first simplifies it,
468+
// and Simplify expands the power: (x + 1 + i / ln(x))^(-16) at +oo, which is 0, took
469+
// 7.8 s for it.
470+
if (!Exponent.ContainsNode(x) && Exponent.Evaled is Real { IsFinite: true, IsZero: false }
471+
&& Base.ComputeLimitDivideEtImpera(x, dist, side) is { } positiveBaseLimit
472+
&& positiveBaseLimit.Evaled is Real { IsPositive: true } positiveBase
473+
&& (positiveBase.IsFinite || positiveBase == Real.PositiveInfinity))
474+
return ComputeLimitImpl(New(positiveBaseLimit, Exponent), x, dist, side);
465475
if (ComputeLimitImpl(this, x, dist, side) is { } lim)
466476
return lim;
467477
var baseLimit = Base.ComputeLimitDivideEtImpera(x, dist, side);
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 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 base tending to a positive number or to +oo, to a constant real exponent, is continuous, and the power's
18+
/// limit is read from the base's. The whole power was simplified first, and Simplify expands it:
19+
/// (x + 1 + i / ln(x))^(-16) at +oo took 7.8 s, and to the power -24 more than 30 s, for 0.
20+
/// Found by limitcheck; no issue was filed.
21+
/// </summary>
22+
[Trait("Area", "Calculus")]
23+
public sealed class APowerOfAPositiveLimitIsContinuousTest
24+
{
25+
[Theory]
26+
[InlineData("(x + 1 + i / ln(x)) ^ (-32)", "0")]
27+
[InlineData("(x + 1 + i / ln(x)) ^ 32", "+oo")]
28+
[InlineData("((x + 1) - log(x, -1)) ^ (2 ^ 3 * (-1 + -1))", "0")]
29+
public void TheLimitAtInfinityIsAnswered(string input, string expected)
30+
{
31+
var limit = Task.Run(() => input.ToEntity().Limit("x", "+oo", ApproachFrom.BothSides));
32+
Assert.True(limit.Wait(TimeSpan.FromSeconds(30)), $"{input} at +oo did not finish in 30 seconds");
33+
Assert.Equal(expected.ToEntity().Evaled, limit.Result.Evaled);
34+
}
35+
36+
[Theory]
37+
[InlineData("(2 + 1 / x) ^ (-3)", "1/8")]
38+
[InlineData("(4 + i / ln(x)) ^ (1/2)", "2")]
39+
[InlineData("(x + 1 + i / ln(x)) ^ (-1/2)", "0")]
40+
public void APositiveOrInfiniteBaseLimitIsRaisedToTheExponent(string input, string expected)
41+
=> Assert.Equal(expected.ToEntity().Evaled, input.ToEntity().Limit("x", "+oo", ApproachFrom.BothSides).Evaled);
42+
}
43+
}

0 commit comments

Comments
 (0)