Skip to content

Commit 9a5503e

Browse files
Read a limit of a quotient over a quotient as a quotient of products (#2394)
Read a limit of a quotient over a quotient as a quotient of products The descent read a / (b / c) as written. x^(-pi) / (ln(2) / ln(x)) at +oo is then 0/0, and l'Hopital's rule makes each step another 0 * oo with a higher power of ln(x), so it was left unevaluated where x^(-pi) ln(x) / ln(2), the same function, is 0. log(x, 2) is ln(2) / ln(x), so x^(-pi) / log(x, 2) was left unevaluated too. Where b is a constant, the quotient is now read first as a c / b, which it equals wherever it has a value, and that reading is kept only where it gives one. x ln(x) at 0 comes back from the descent as 0 * (-oo), and taking that as the answer made x / log(x, 2) from both sides of 0 NaN where it is 0; there the quotient is read as written, as before. Over a b that is not constant, x^x / (x / x) read as x^x x / x took twenty times as long. Found by limitcheck; no issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d682f0d commit 9a5503e

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,25 @@ filed.
107107
| `"floor(log(x - 1, x))".ToEntity().Limit("x", 1, ApproachFrom.Right)` | `limitright(floor(log(x - 1, x)), x, 1)` | `-1` |
108108
| `"floor(x / log(x, x))".ToEntity().Limit("x", 0, ApproachFrom.Left)` | `limitleft(floor(x / log(x, x)), x, 0)` | `-1` |
109109

110+
### A limit of a quotient over a quotient is read as a quotient of products
111+
112+
**Silent: in a limit, `a / (b / c)` with `b` constant is read first as `a c / b`, and that reading is kept where it gives
113+
a value.** Read as written, `x^(-pi) / (ln(2) / ln(x))` at +oo is 0/0, and each step of l'Hopital's rule gave another
114+
0 * oo with a higher power of `ln(x)`, so it was left unevaluated. `log(x, 2)` is `ln(2) / ln(x)`, so any logarithm in
115+
a divisor met this. Where the new reading gives no value -- `x ln(x)` at 0 is `0 * (-oo)` to it -- the quotient is read
116+
as written, as before, and `x / log(x, 2)` at 0 is still 0. A two-sided limit that 2.6.0 answered and the master
117+
before this change made NaN is answered again. Found by limitcheck; no issue was filed.
118+
119+
| Input | Was (2.6.0) | Now |
120+
|---|---|---|
121+
| `"x^(-pi) / log(x, 2)".ToEntity().Limit("x", "+oo")` | `limit(x ^ (-pi) / log(x, 2), x, +oo)` | `0` |
122+
| `"x^(-pi) / (ln(2) / ln(x))".ToEntity().Limit("x", "+oo")` | `limit(x ^ (-pi) / (ln(2) / ln(x)), x, +oo)` | `0` |
123+
| `"(1/x)^pi / log(1/x, 2)".ToEntity().Limit("x", "+oo")` | `limit((1 / x) ^ pi / log(1 / x, 2), x, +oo)` | `0` |
124+
| `"arcsin(pi + x) / (1/x)".ToEntity().Limit("x", 0)`, and from either side | `limit(arcsin(pi + x) / (1 / x), x, 0)` | `0` |
125+
| `"tan(1/2) / log(x, -1) / tanh(sin(x))".ToEntity().Limit("x", 1, ApproachFrom.Left)` | `limitleft(tan(1/2) / log(x, -1) / ((e ^ (2 * sin(x)) - 1) / (e ^ (2 * sin(x)) + 1)), x, 1)` | `0` |
126+
| `"tan(1/2) / log(x, -1) / tanh(sin(x))".ToEntity().Limit("x", 1)` | `NaN` | `0` |
127+
| `"tanh(exp(pi)) / log(log(-1, x), 2)".ToEntity().Limit("x", -1)` | `0`, and `NaN` on master before this change | `0` |
128+
110129
### A logarithm of a power is read through the logarithm of its base in a limit
111130

112131
**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

‎Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ partial record Divf
149149
{
150150
internal override Entity? ComputeLimitDivideEtImpera(Variable x, Entity dist, ApproachFrom side)
151151
{
152+
// Over a quotient, as a quotient of products: a / (b / c) is a c / b wherever it has a value. Read as written,
153+
// x^(-pi) / (ln(2) / ln(x)) at +oo is 0/0, and l'Hopital's rule makes each step of it another 0 * oo with a
154+
// higher power of ln(x), so it was left unevaluated where x^(-pi) ln(x) / ln(2) is 0 at once. Only a value is
155+
// taken from it. x ln(x) at 0 comes back as 0 * (-oo), which is no answer, and from both sides that was read
156+
// as NaN, where x / log(x, 2) read as written is 0. And only over a constant: x^x / (x / x) as a product is
157+
// x^x x / x, which took twenty times as long and answered from both sides of 0 where x^x itself is NaN.
158+
if (Divisor is Divf(var over, var under) && under.ContainsNode(x) && !over.ContainsNode(x)
159+
&& New(Dividend * under, over).ComputeLimitDivideEtImpera(x, dist, side) is { } asProducts
160+
&& !asProducts.ContainsNode(x) && asProducts.Evaled != MathS.NaN)
161+
return asProducts;
152162
// A form with no value -- 0 * +oo / 0, which is what -x / (sqrt(1 - x^2) * arcsin(x)) at 0
153163
// from the right comes back as -- is the claim that there is no limit, and the parts may
154164
// say otherwise. It is kept for the end, where it was answered before, and the parts are
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 quotient whose divisor is a quotient was read as written. x^(-pi) / (ln(2) / ln(x)) at +oo is then 0/0, and
16+
/// l'Hopital's rule makes each step of it another 0 * oo with a higher power of ln(x), so it was left unevaluated
17+
/// where x^(-pi) ln(x) / ln(2), the same function, is 0. log(x, 2) is ln(2) / ln(x), so x^(-pi) / log(x, 2) was
18+
/// left unevaluated too. The reading as a quotient of products is taken only where it gives a value: x ln(x) at 0
19+
/// is 0 * (-oo) to it, and x / log(x, 2) from both sides of 0 stays 0. Found by limitcheck; no issue was filed.
20+
/// </summary>
21+
[Trait("Area", "Calculus")]
22+
public sealed class AQuotientOverAQuotientTest
23+
{
24+
[Theory]
25+
[InlineData("x^(-pi) / (ln(2) / ln(x))", "+oo", ApproachFrom.BothSides, "0")]
26+
[InlineData("x^(-pi) / log(x, 2)", "+oo", ApproachFrom.BothSides, "0")]
27+
[InlineData("(1/x)^pi / log(1/x, 2)", "+oo", ApproachFrom.BothSides, "0")]
28+
[InlineData("arcsin(pi + x) / (1 / x)", "0", ApproachFrom.BothSides, "0")]
29+
[InlineData("tan(1/2) / log(x, -1) / tanh(sin(x))", "1", ApproachFrom.Left, "0")]
30+
[InlineData("tanh(exp(pi)) / log(log(-1, x), 2)", "-1", ApproachFrom.BothSides, "0")]
31+
// Read as written, and not as x ln(x) / ln(2), whose limit from both sides was NaN.
32+
[InlineData("x / log(x, 2)", "0", ApproachFrom.BothSides, "0")]
33+
[InlineData("x ^ log(pi + 1, x - 1)", "1", ApproachFrom.BothSides, "1")]
34+
public void IsReadAsAQuotientOfProducts(string input, string destination, ApproachFrom side, string expected)
35+
=> Assert.Equal(expected.ToEntity(), input.ToEntity().Limit("x", destination, side));
36+
37+
// The divisor's own divisor vanishing does not make the quotient vanish: x / (1 / x) is x^2, +oo at +oo.
38+
[Fact]
39+
public void TheInnerDivisorIsAFactorOfTheDividend()
40+
=> Assert.Equal("+oo".ToEntity(), "x / (1 / x)".ToEntity().Limit("x", "+oo", ApproachFrom.BothSides));
41+
}
42+
}

0 commit comments

Comments
 (0)