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
19 changes: 19 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ A bare `floor(x)` or `sgn(x)` was already declined there. Away from a jump, noth
| `"limit(floor(x) + x, x, 1)".ToEntity().Simplify()` | `2` | `limit(floor(x) + x, x, 1)` |
| `"limitleft(-sgn(x), x, 0)".ToEntity().Simplify()` | `0` | `limitleft(-sgn(x), x, 0)` |

### A step function arriving at 0 is answered from the side its argument arrives from

**Silent: a limit of `floor` or `ceil` whose argument tends to 0 is answered where the argument keeps one sign on the
way in, and that sign was known for the argument itself but not asked of it.** The step asks the sign of its argument
less 0, and that difference was not read as the argument: `x^(3/2)` at 0 from the right is a positive base to a real
power, and `1/x` at -oo is negative, but `x^(3/2) - 0` and `1/x - 0` had no sign. A step arriving at any other
integer, and an argument that is not real on the side approached, are unchanged. Found by limitcheck; no issue was
filed.

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"floor(x^(3/2))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(floor(x ^ (3/2)), x, 0)` | `0` |
| `"floor(sqrt(x^3))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | `limitright(floor(sqrt(x ^ 3)), x, 0)` | `0` |
| `"floor(1/x)".ToEntity().Limit("x", "+oo")` | `limit(floor(1 / x), x, +oo)` | `0` |
| `"floor(1/x)".ToEntity().Limit("x", "-oo")` | `limit(floor(1 / x), x, -oo)` | `-1` |
| `"floor(e^x)".ToEntity().Limit("x", "-oo")` | `limit(floor(e ^ x), x, -oo)` | `0` |
| `"floor(log(x - 1, x))".ToEntity().Limit("x", 1, ApproachFrom.Right)` | `limitright(floor(log(x - 1, x)), x, 1)` | `-1` |
| `"floor(x / log(x, x))".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(floor(x / log(x, x)), x, 0)` | `-1` |

### A logarithm of a power is read through the logarithm of its base in a limit

**Silent: in a limit, the logarithm of a power to a constant real exponent, `log(f^c)`, is read as `c log(f)`, or as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1241,9 +1241,13 @@ private static ApproachFrom[] Sides(Entity dest, ApproachFrom side)
// A product or a quotient has the product of its parts' signs: sqrt(x) * x at 0 from the
// right has the slope sqrt(x), which tends to 0, and so had no sign. A positive base to a
// real power is positive: sqrt(1/x) at +oo has no slope to read, and e^x at -oo none either.
// A difference with 0 is read as what it subtracts 0 from: a step function at a jump of 0 and a
// comparison with 0 both ask about g - 0, and floor(x^(3/2)) at 0 from the right was declined
// for want of the sign x^(3/2) has as a power.
private static int? SignOfTheFactors(Entity expr, Variable x, Entity dest, ApproachFrom side)
=> expr switch
{
Minusf(var minuend, Integer { IsZero: true }) => SignNear(minuend, x, dest, side),
Mulf(var left, var right) => SignOfTheProduct(left, right, x, dest, side),
Divf(var left, var right) => SignOfTheProduct(left, right, x, dest, side),
Powf(var @base, var exponent) when IsRealNear(exponent, x, dest, side)
Expand Down
37 changes: 37 additions & 0 deletions Sources/Tests/UnitTests/Calculus/AStepAtAVanishingPowerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// 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;
using static AngouriMath.Entity;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// A step function at a jump of 0 asks the sign its argument less 0 keeps on the side approached.
/// That difference was not read as the power it subtracts 0 from, so <c>floor(x^(3/2))</c> at 0 from
/// the right was declined: its second derivative diverges there, and its slope, <c>sqrt(x)</c>, tends
/// to 0. Found by limitcheck; no issue was filed.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class AStepAtAVanishingPowerTest
{
[Theory]
[InlineData("floor(x^(3/2))", "0")]
[InlineData("floor(x^pi)", "0")]
[InlineData("floor(x^2 * sqrt(x))", "0")]
[InlineData("ceil(-x * sqrt(x))", "0")]
[InlineData("ceil(x^(3/2))", "1")]
public void IsAnsweredFromTheRight(string input, string expected)
=> Assert.Equal(MathS.FromString(expected), MathS.FromString(input).Limit("x", 0, ApproachFrom.Right));

// On the left x^(3/2) is not real, and nothing here reads the side its imaginary part arrives from.
[Fact]
public void IsLeftAloneFromTheLeft()
=> Assert.IsType<Limitf>(MathS.FromString("floor(x^(3/2))").Limit("x", 0, ApproachFrom.Left));
}
}
Loading