Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,16 @@ partial record Powf
{
internal override Entity? ComputeLimitDivideEtImpera(Variable x, Entity dist, ApproachFrom side)
{
// A base tending to a positive number or to +oo, to a constant real exponent that is
// not 0, is continuous there: the power tends to the base's limit to that exponent,
// and nothing about the whole has to be read. Asking the whole first simplifies it,
// and Simplify expands the power: (x + 1 + i / ln(x))^(-16) at +oo, which is 0, took
// 7.8 s for it.
if (!Exponent.ContainsNode(x) && Exponent.Evaled is Real { IsFinite: true, IsZero: false }
&& Base.ComputeLimitDivideEtImpera(x, dist, side) is { } positiveBaseLimit
&& positiveBaseLimit.Evaled is Real { IsPositive: true } positiveBase
&& (positiveBase.IsFinite || positiveBase == Real.PositiveInfinity))
return ComputeLimitImpl(New(positiveBaseLimit, Exponent), x, dist, side);
if (ComputeLimitImpl(this, x, dist, side) is { } lim)
return lim;
var baseLimit = Base.ComputeLimitDivideEtImpera(x, dist, side);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Copyright (c) 2019-2026 Angouri.
// AngouriMath is licensed under MIT.
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
// Website: https://am.angouri.org.
//

using System;
using System.Threading.Tasks;
using AngouriMath.Core;
using AngouriMath.Extensions;
using Xunit;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// A base tending to a positive number or to +oo, to a constant real exponent, is continuous, and the power's
/// limit is read from the base's. The whole power was simplified first, and Simplify expands it:
/// (x + 1 + i / ln(x))^(-16) at +oo took 7.8 s, and to the power -24 more than 30 s, for 0.
/// Found by limitcheck; no issue was filed.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class APowerOfAPositiveLimitIsContinuousTest
{
[Theory]
[InlineData("(x + 1 + i / ln(x)) ^ (-32)", "0")]
[InlineData("(x + 1 + i / ln(x)) ^ 32", "+oo")]
[InlineData("((x + 1) - log(x, -1)) ^ (2 ^ 3 * (-1 + -1))", "0")]
public void TheLimitAtInfinityIsAnswered(string input, string expected)
{
var limit = Task.Run(() => input.ToEntity().Limit("x", "+oo", ApproachFrom.BothSides));
Assert.True(limit.Wait(TimeSpan.FromSeconds(30)), $"{input} at +oo did not finish in 30 seconds");
Assert.Equal(expected.ToEntity().Evaled, limit.Result.Evaled);
}

[Theory]
[InlineData("(2 + 1 / x) ^ (-3)", "1/8")]
[InlineData("(4 + i / ln(x)) ^ (1/2)", "2")]
[InlineData("(x + 1 + i / ln(x)) ^ (-1/2)", "0")]
public void APositiveOrInfiniteBaseLimitIsRaisedToTheExponent(string input, string expected)
=> Assert.Equal(expected.ToEntity().Evaled, input.ToEntity().Limit("x", "+oo", ApproachFrom.BothSides).Evaled);
}
}
Loading