Skip to content

Commit a5f5bc8

Browse files
Read a power's sign from its base before its slope in a limit (#2414)
* Read a power's sign from its base before its slope in a limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 52497e3 commit a5f5bc8

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,11 @@ private static ApproachFrom[] Sides(Entity dest, ApproachFrom side)
12691269
if (dest.Evaled is Real { IsFinite: false, IsNaN: false } infinity)
12701270
return SignFromVanishingOrder(expr.Substitute(x, infinity.IsNegative ? -1 / x : 1 / x), x, Integer.Zero, ApproachFrom.Right)
12711271
?? SignOfTheFactors(expr, x, dest, side) ?? SignThroughAChangeOfVariable(expr, x, dest, side);
1272-
return SignFromVanishingOrder(expr, x, dest, side) ?? SignFromTheSlope(expr, x, dest, side)
1272+
// A power is read by its base before its slope: a positive base to a real power is positive, and the base is
1273+
// the smaller question. sgn((x * x)^arctan(1/2)) at 0 from the left asked for the slope of the power, which
1274+
// l'Hopital's rule took 6.6 s over, for the sign x * x has as a product.
1275+
return SignFromVanishingOrder(expr, x, dest, side)
1276+
?? (expr is Powf ? SignOfTheFactors(expr, x, dest, side) : null) ?? SignFromTheSlope(expr, x, dest, side)
12731277
?? SignOfTheFactors(expr, x, dest, side) ?? SignThroughAChangeOfVariable(expr, x, dest, side);
12741278
}
12751279

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
/// The sign a power keeps near a point is read from its base before its slope: a positive base to a real power is
18+
/// positive. sgn((x * x)^arctan(1/2)) at 0 from the left asked for the slope of the power first, which l'Hopital's
19+
/// rule took 6.6 s over, for 1. Found by limitcheck; no issue was filed.
20+
/// </summary>
21+
[Trait("Area", "Calculus")]
22+
public sealed class APowerHasTheSignOfItsBaseTest
23+
{
24+
[Theory]
25+
[InlineData("sgn((x * x) ^ arctan(1/2))", ApproachFrom.Left, "1")]
26+
[InlineData("sgn((x * x) ^ arctan(1/2))", ApproachFrom.BothSides, "1")]
27+
[InlineData("floor((x * x) ^ pi)", ApproachFrom.Left, "0")]
28+
public void TheLimitAtZeroIsAnswered(string input, ApproachFrom side, string expected)
29+
{
30+
var limit = Task.Run(() => input.ToEntity().Limit("x", 0, side));
31+
Assert.True(limit.Wait(TimeSpan.FromSeconds(30)), $"{input} at 0 from {side} did not finish in 30 seconds");
32+
Assert.Equal(expected.ToEntity().Evaled, limit.Result.Evaled);
33+
}
34+
35+
// A negative base to a power that is not whole is complex on that side, and has no sign.
36+
[Fact]
37+
public void AComplexPowerHasNoSign()
38+
=> Assert.IsType<Entity.Limitf>("sgn((x * x * x) ^ pi)".ToEntity().Limit("x", 0, ApproachFrom.Left));
39+
}
40+
}

0 commit comments

Comments
 (0)