Skip to content

Commit 71ef76e

Browse files
Read the side a quotient arrives at a constant from by its parts in a limit (#2415)
* Read the side a quotient arrives at a constant from by its parts in a limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a5f5bc8 commit 71ef76e

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,21 @@ answers the same rows as before, except the three below that did not finish.
135135
| `"((x + 1) - log(x, -1)) ^ (-16)".ToEntity().Limit("x", 1, ApproachFrom.Right)` | did not finish in 30 s | `0` |
136136
| `"((x + 1) - log(x, -1)) ^ (-16)".ToEntity().Limit("x", 1, ApproachFrom.BothSides)` | did not finish in 30 s | `0` |
137137

138+
### A step function of a quotient tending to a constant is answered from the quotient's parts in a limit
139+
140+
**Silent: the side a quotient `a / b` arrives at a constant `c` from is read as the sign of `a - c b` times that of
141+
`b`**, so a step function of it is answered. `log(x / 2, tan(x))` at 0 from the right is `ln(tan(x)) / ln(x / 2)`,
142+
which tends to 1. `ln(tan(x)) - ln(x / 2)` tends to `ln(2)` and `ln(x / 2)` to -oo, so the quotient arrives from below,
143+
and its floor is 0. Since 2.6.0 these were also declined only after 10 to 19 s, spent in l'Hôpital's rule on the slope.
144+
Found by limitcheck; no issue was filed.
145+
146+
| Input | Was (2.6.0) | Now |
147+
|---|---|---|
148+
| `"floor(log(x / 2, tan(x)))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |
149+
| `"floor(log(pi / x, tan(x)))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `-1` |
150+
| `"floor(tanh(1 / x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |
151+
| `"floor(tanh(1 / x))".ToEntity().Limit("x", 0)` | unevaluated | `NaN`: the left side is `-1` |
152+
138153
### A logarithm of a part tending to 1 is read as the part less 1 in a limit
139154

140155
**Silent: a factor `ln(u)` whose antilogarithm tends to 1 is read as `u - 1`, as `sin(f)` is read as `f` where `f`

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,10 +1273,25 @@ private static ApproachFrom[] Sides(Entity dest, ApproachFrom side)
12731273
// the smaller question. sgn((x * x)^arctan(1/2)) at 0 from the left asked for the slope of the power, which
12741274
// l'Hopital's rule took 6.6 s over, for the sign x * x has as a product.
12751275
return SignFromVanishingOrder(expr, x, dest, side)
1276-
?? (expr is Powf ? SignOfTheFactors(expr, x, dest, side) : null) ?? SignFromTheSlope(expr, x, dest, side)
1276+
?? (expr is Powf ? SignOfTheFactors(expr, x, dest, side) : null) ?? SignOfAQuotientLessAConstant(expr, x, dest, side)
1277+
?? SignFromTheSlope(expr, x, dest, side)
12771278
?? SignOfTheFactors(expr, x, dest, side) ?? SignThroughAChangeOfVariable(expr, x, dest, side);
12781279
}
12791280

1281+
// A quotient less a constant, a / b - c, is the one quotient (a - c b) / b, and has the sign of a - c b times that
1282+
// of b, which are two smaller questions than its slope. floor(log(x / 2, tan(x))) at 0 from the right is the
1283+
// floor of ln(tan(x)) / ln(x / 2), which tends to 1, and asks the sign of that less 1: a - b tends to ln(2) and
1284+
// b to -oo, so it is negative, and the floor is 0. Read through the slope, l'Hopital's rule spent 20 s and
1285+
// declined, and the limit was left unevaluated.
1286+
private static int? SignOfAQuotientLessAConstant(Entity expr, Variable x, Entity dest, ApproachFrom side)
1287+
=> expr switch
1288+
{
1289+
Minusf(Divf(var dividend, var divisor), var constant) when !constant.ContainsNode(x)
1290+
=> SignNear(dividend - constant * divisor, x, dest, side) is { } top && SignNear(divisor, x, dest, side) is { } bottom
1291+
? top * bottom : null,
1292+
_ => null
1293+
};
1294+
12801295
// Where the variable is only ever inside one part u, the expression is h(u), and near the destination it has the
12811296
// sign h(t) has as t tends to the limit of u, from the side u arrives from. sinh(e^x) at -oo is (e^t - e^-t) / 2
12821297
// at 0 from the right, which has a slope; read at -oo itself, through 1/x, it is flat, every derivative of
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
/// The side a quotient a / b arrives at a constant c from is the sign of a - c b times that of b. floor(log(x / 2, tan(x)))
16+
/// at 0 from the right is the floor of ln(tan(x)) / ln(x / 2), which tends to 1 from below, since ln(tan(x)) - ln(x / 2)
17+
/// tends to ln(2) and ln(x / 2) to -oo. It was left unevaluated after 20 s in l'Hopital's rule on the slope.
18+
/// Found by limitcheck; no issue was filed.
19+
/// </summary>
20+
[Trait("Area", "Calculus")]
21+
public sealed class AQuotientArrivesByItsPartsTest
22+
{
23+
[Theory]
24+
[InlineData("floor(log(x / 2, tan(x)))", "0")]
25+
[InlineData("floor(log(pi / x, tan(x)))", "-1")]
26+
[InlineData("floor(ln(tan(x)) / ln(x / 2))", "0")]
27+
[InlineData("ceil(ln(tan(x)) / ln(x / 2))", "1")]
28+
[InlineData("floor(tanh(1 / x))", "0")]
29+
public void TheLimitFromTheRightIsAnswered(string input, string expected)
30+
=> Assert.Equal(expected.ToEntity().Evaled, input.ToEntity().Limit("x", 0, ApproachFrom.Right).Evaled);
31+
32+
// tanh(1 / x) is (e^(2 / x) - 1) / (e^(2 / x) + 1), which arrives at 1 from below on the right and at -1 from above on
33+
// the left, so its floor is 0 on one side and -1 on the other, and the two-sided limit does not exist.
34+
[Fact]
35+
public void TheSidesOfAQuotientCanDisagree()
36+
{
37+
Assert.Equal(MathS.FromString("-1"), MathS.FromString("floor(tanh(1 / x))").Limit("x", 0, ApproachFrom.Left).Evaled);
38+
Assert.Equal(MathS.NaN, MathS.FromString("floor(tanh(1 / x))").Limit("x", 0));
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)