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 @@ -1298,13 +1298,16 @@ private static ApproachFrom[] Sides(Entity dest, ApproachFrom side)
// 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
// 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,
// whose own u - L is (1 + e^x) - 1 again, and that recursion overflowed the stack. Its next part, e^x, answers.
// 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),
// 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.
private static int? SignThroughAChangeOfVariable(Entity expr, Variable x, Entity dest, ApproachFrom side)
{
var t = Variable.CreateTemp(expr.Vars);
foreach (var part in expr.Nodes)
{
if (ReferenceEquals(part, expr) || part == x || !part.ContainsNode(x)
|| expr.Substitute(part, t) is not { } outer || outer.ContainsNode(x))
|| expr.Substitute(part, t) is not { } outer || outer.ContainsNode(x)
|| !IsRealOnEachSide(part, x, dest, side))
continue;
if (EvalAssumingContinuous(part.Limit(x, dest, side)) is not Real { IsNaN: false } limit)
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 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 AngouriMath.Core;
using AngouriMath.Extensions;
using Xunit;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// 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.
/// 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
/// 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,
/// as they were in 2.6.0. Found by limitcheck; no issue was filed.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class AComplexPartIsNotARealVariableTest
{
[Theory]
[InlineData("floor(exp(ln(x)))", ApproachFrom.Left)]
[InlineData("floor(exp(ln(x)))", ApproachFrom.BothSides)]
[InlineData("sgn(exp(ln(x)))", ApproachFrom.Left)]
[InlineData("floor(exp(ln(x)) + 1)", ApproachFrom.Left)]
public void ThePositiveReadingIsNotGiven(string input, ApproachFrom side)
=> Assert.IsType<Entity.Limitf>(input.ToEntity().Limit("x", 0, side));

[Fact]
public void TheRightSideIsStillAnswered()
=> Assert.Equal(MathS.FromString("0"), "floor(exp(ln(x)))".ToEntity().Limit("x", 0, ApproachFrom.Right).Evaled);
}
}
Loading