Skip to content

Commit 15070c6

Browse files
Let a two-sided limit through a real function of a real argument take the sides' common value (#2418)
* Read a tangent, an error function and a step function as real when a limit's sides are compared Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f17be26 commit 15070c6

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ Found by limitcheck; no issue was filed.
164164
| `"floor(tanh(1 / x))".ToEntity().Limit("x", 0, ApproachFrom.Right)` | unevaluated | `0` |
165165
| `"floor(tanh(1 / x))".ToEntity().Limit("x", 0)` | unevaluated | `NaN`: the left side is `-1` |
166166

167+
### A two-sided limit through a real function of a real argument is the sides' common value
168+
169+
**Silent: a tangent, an arccotangent, an error function and a step function of a real argument are read as real when
170+
the two sides of a two-sided limit are compared**, as a sine, a cosine and an arctangent already were. Their sides were
171+
not compared at all, and where the descent read a side as `0 * oo`, the limit was `NaN`, which says it does not exist.
172+
Since 2.6.0, master answered `NaN` for these. Found by limitcheck; no issue was filed.
173+
174+
| Input | Was (2.6.0) | Now |
175+
|---|---|---|
176+
| `"(pi^2 + (1/2) / x) * erf(x)".ToEntity().Limit("x", 0)` | `limit((pi * pi + 1/2 / x) * erf(x), x, 0)` | `1 / sqrt(pi)` |
177+
| `"(1 + 1/x) * erf(x)".ToEntity().Limit("x", 0)` | `limit((1 + 1 / x) * erf(x), x, 0)` | `2 * 1 / sqrt(pi)` |
178+
| `"(abs(x)^(x/pi))^sgn(x)".ToEntity().Limit("x", 0)` | `limit((abs(x) ^ (x / pi)) ^ sgn(x), x, 0)` | `1` |
179+
167180
### A logarithm of a part tending to 1 is read as the part less 1 in a limit
168181

169182
**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/Solvers/Solvers.Definition.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ bool RealThere(Entity node)
246246
Arctanf(var argument) => RealThere(argument),
247247
Arcsinf(var argument) => RealThere(argument) && StrictlyInsideTheUnitInterval(argument),
248248
Arccosf(var argument) => RealThere(argument) && StrictlyInsideTheUnitInterval(argument),
249+
// So are a tangent and an arccotangent, the error functions, and the step functions, of a real
250+
// argument. (pi^2 + 1/(2x)) erf(x) at 0 was NaN, where each side is 1/sqrt(pi).
251+
Tanf(var argument) => RealThere(argument),
252+
Arccotanf(var argument) => RealThere(argument),
253+
Erff(var argument) => RealThere(argument),
254+
Erfcf(var argument) => RealThere(argument),
255+
Erfif(var argument) => RealThere(argument),
256+
Floorf(var argument) => RealThere(argument),
257+
Ceilf(var argument) => RealThere(argument),
258+
Roundf(var argument) => RealThere(argument),
259+
Signumf(var argument) => RealThere(argument),
249260
_ => false
250261
};
251262
}
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.Extensions;
9+
using Xunit;
10+
11+
namespace AngouriMath.Tests.Calculus
12+
{
13+
/// <summary>
14+
/// A two-sided limit compares its sides only where the expression is known to be real on both, and an error function
15+
/// or a step function of a real argument was not known to be. (pi^2 + 1/(2x)) erf(x) at 0 was NaN, which says there
16+
/// is no limit, where each side is 1/sqrt(pi). Found by limitcheck; no issue was filed.
17+
/// </summary>
18+
[Trait("Area", "Calculus")]
19+
public sealed class ARealFunctionAgreesOnBothSidesTest
20+
{
21+
[Theory]
22+
[InlineData("(pi^2 + (1/2) / x) * erf(x)", "1 / sqrt(pi)")]
23+
[InlineData("(1 + 1/x) * erf(x)", "2 / sqrt(pi)")]
24+
[InlineData("(abs(x)^(x/pi))^sgn(x)", "1")]
25+
public void TheSidesAgree(string input, string expected)
26+
{
27+
var limit = input.ToEntity().Limit("x", 0);
28+
Assert.False(limit.ContainsNode("x"), $"the limit of {input} was not taken: {limit}");
29+
var difference = (limit - expected.ToEntity()).EvalNumerical();
30+
Assert.True(difference is Entity.Number.Real { IsFinite: true } real && real.Abs() < 1e-20, $"the limit of {input} is {limit}, not {expected}");
31+
}
32+
33+
// Where the sides differ there is still no limit.
34+
[Theory]
35+
[InlineData("floor(x)")]
36+
[InlineData("sgn(x)")]
37+
[InlineData("erfc(x) / x")]
38+
public void TheSidesStillDiffer(string input)
39+
=> Assert.Equal(MathS.NaN, input.ToEntity().Limit("x", 0));
40+
}
41+
}

0 commit comments

Comments
 (0)