Skip to content

Commit 58de4fb

Browse files
Read a sign through a change of variable only for a real part in a limit (#2416)
* Read a sign through a change of variable only for a real part in a limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 71ef76e commit 58de4fb

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,13 +1298,16 @@ private static ApproachFrom[] Sides(Entity dest, ApproachFrom side)
12981298
// e^(-1/x) vanishing at 0, so nothing had a sign for it. u is a proper part, and the side u arrives from is the
12991299
// sign of u - L, which is skipped where it is this very expression: ln(1 + e^x) at -oo asks it of (1 + e^x) - 1,
13001300
// whose own u - L is (1 + e^x) - 1 again, and that recursion overflowed the stack. Its next part, e^x, answers.
1301+
// t is real, so u has to be real on the side approached: ln(x) on the left of 0 is ln|x| + i pi, and e^ln(x),
1302+
// which is x and negative there, was read as e^t at -oo, positive, so floor(e^ln(x)) at 0 from the left was 0.
13011303
private static int? SignThroughAChangeOfVariable(Entity expr, Variable x, Entity dest, ApproachFrom side)
13021304
{
13031305
var t = Variable.CreateTemp(expr.Vars);
13041306
foreach (var part in expr.Nodes)
13051307
{
13061308
if (ReferenceEquals(part, expr) || part == x || !part.ContainsNode(x)
1307-
|| expr.Substitute(part, t) is not { } outer || outer.ContainsNode(x))
1309+
|| expr.Substitute(part, t) is not { } outer || outer.ContainsNode(x)
1310+
|| !IsRealOnEachSide(part, x, dest, side))
13081311
continue;
13091312
if (EvalAssumingContinuous(part.Limit(x, dest, side)) is not Real { IsNaN: false } limit)
13101313
return null;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 sign read through a change of variable puts a real t for a part u, so u has to be real on the side approached.
16+
/// ln(x) on the left of 0 is ln|x| + i pi, and e^ln(x), which is x and negative there, was read as e^t at -oo, which is
17+
/// positive: floor(e^ln(x)) at 0 from the left was 0 and sgn(e^ln(x)) was 1, where both are -1. They are declined now,
18+
/// as they were in 2.6.0. Found by limitcheck; no issue was filed.
19+
/// </summary>
20+
[Trait("Area", "Calculus")]
21+
public sealed class AComplexPartIsNotARealVariableTest
22+
{
23+
[Theory]
24+
[InlineData("floor(exp(ln(x)))", ApproachFrom.Left)]
25+
[InlineData("floor(exp(ln(x)))", ApproachFrom.BothSides)]
26+
[InlineData("sgn(exp(ln(x)))", ApproachFrom.Left)]
27+
[InlineData("floor(exp(ln(x)) + 1)", ApproachFrom.Left)]
28+
public void ThePositiveReadingIsNotGiven(string input, ApproachFrom side)
29+
=> Assert.IsType<Entity.Limitf>(input.ToEntity().Limit("x", 0, side));
30+
31+
[Fact]
32+
public void TheRightSideIsStillAnswered()
33+
=> Assert.Equal(MathS.FromString("0"), "floor(exp(ln(x)))".ToEntity().Limit("x", 0, ApproachFrom.Right).Evaled);
34+
}
35+
}

0 commit comments

Comments
 (0)