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
14 changes: 14 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ root near 23.
| `"x^7 - 5x^6 + 1 = 0".Solve("x")` | six roots, none of them near 5 | seven roots |
| `"x^4 - 3*x^(5/2) + 2 = 0".Solve("x")` | `{ 1, 4.8870…^(2/5) }` | four roots: `1`, `1.3734…^2`, and two off the real line |

### A complex constant does not make the two sides of a limit differ

**A two-sided limit with a complex constant in it is answered where each side is, where it was NaN.** Where the
descent cannot compare the two sides, each is asked through the whole of the machinery, but only of an expression
real on both sides, and every constant had to be real. `pi^2 / log(x, -2)` is `pi^2 ln(x) / ln(-2)`, which is 0 from
each side of 1. A constant is the same number on both sides, so a complex one is now allowed; what depends on the
variable is read as before, and `x^x`, `x ln(x)` and `x^i` at 0 are NaN as they were.

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"pi^2 / log(x, -2)".ToEntity().Limit("x", 1)` | `NaN` | `0` |
| `"(log(1/2, 1) + pi^2) / log(x, -2)".ToEntity().Limit("x", 1)` | `NaN` | `0` |
| `"log(x ^ (-1), -1) ^ 2".ToEntity().Limit("x", 1)` | `NaN` | `-oo` |

### A step function reads the side its argument arrives from off the slope

**A one-sided limit of a floor or a ceiling whose argument arrives at a jump like a root is answered, where it was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ node is Floorf or Ceilf or Roundf or Signumf

/// <summary>
/// Whether <paramref name="expr"/> is real on both sides of a real <paramref name="dest"/>,
/// close enough to it, decided structurally: every power to an exponent that is not whole,
/// close enough to it, but for its constants, decided structurally: every power to an exponent that is not whole,
/// and every logarithm, has a base and an argument positive on both sides, by
/// <see cref="SignNear"/>. Where it is, its one-sided limits are limits of real values from
/// <see cref="SignNear"/>. Where it is, its one-sided limits are limits of values it takes on
/// either side, and their agreeing is the two-sided limit under any codomain. <c>x^x</c>
/// is not, its base being negative on the left, and stays without one; <c>(x^2)^x</c> is,
/// and was NaN at 0 where each side is 1. Anything else unlisted is not real, which costs
Expand All @@ -217,8 +217,12 @@ private static bool IsRealOnBothSides(Entity expr, Variable x, Entity dest)
return RealThere(expr);
bool RealThere(Entity node)
{
// A constant is the same number on both sides, so a complex one does not make
// them differ: pi^2 / log(x, -2), which is pi^2 ln(x) / ln(-2), is 0 from each
// side of 1 and was NaN. What a side could differ in is a part that depends on x,
// and those are read below as before.
if (!node.ContainsNode(x))
return node.Evaled is Real { IsFinite: true };
return node.Evaled is Complex { IsFinite: true };
return node switch
{
Variable variable => variable == x,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// 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 Xunit;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// A two-sided limit whose sides the descent could not compare asks each side through the whole of the machinery,
/// but only of an expression real on both sides, and a constant was required to be real. <c>pi^2 / log(x, -2)</c> is
/// <c>pi^2 ln(x) / ln(-2)</c>, 0 from each side of 1, and its two-sided limit was NaN. A constant is the same number
/// on both sides, so a complex one does not make them differ. Found by limitcheck at <c>DEPTH=3</c>, <c>SEED=69</c>;
/// no issue was filed.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class AComplexConstantIsTheSameOnBothSidesTest
{
[Theory]
[InlineData("pi^2 / log(x, -2)", "1", "0")]
[InlineData("(log(1/2, 1) + pi^2) / log(x, -2)", "1", "0")]
[InlineData("log(x ^ (-1), -1) ^ 2", "1", "-oo")]
public void IsWhereBothSidesAgree(string input, string destination, string expected)
=> Assert.Equal(MathS.FromString(expected).Simplify(),
MathS.FromString(input).Limit("x", destination).Simplify());

// Where a part that depends on x is not real on one side, or the sides differ, there is still no limit.
[Theory]
[InlineData("i * sgn(x)", "0")]
[InlineData("(2 + i) / x", "0")]
[InlineData("x ^ x", "0")]
[InlineData("x ^ i", "0")]
[InlineData("x * ln(x)", "0")]
[InlineData("ln(-2) / ln(x)", "1")]
public void IsStillNaNWhereTheSidesDiffer(string input, string destination)
=> Assert.Equal(MathS.NaN, MathS.FromString(input).Limit("x", destination));
}
}
Loading