diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md
index fad9d71b9..ef98bf198 100644
--- a/BREAKING-CHANGES.md
+++ b/BREAKING-CHANGES.md
@@ -796,6 +796,39 @@ whose quotient of derivatives tends to 0 where the quotient tends to 1, is left
| `x^(x - 1) * ln(x)` at 0 | unevaluated | `NaN` |
| `x^(x - 1) / x` at 0; `x^(x - 1/3)` at 0 from the left; `x^x`, `sin(x)^x` there | `NaN`; unevaluated; `1`, `1` | unchanged |
+### (1 + u)^(1/u) is not e where its error is multiplied by something that grows
+
+**Silent: wrong limits become right ones, and unevaluated ones values.** `(1 + u)^(1/u)` tends to `e` with an error of
+order `u`, and two readings put `e` in its place where that error mattered. The second remarkable limit rewrote every
+such power inside the expression, not only the expression itself, so `(e - (1 + 1/x)^x) x` at `+oo` was `(e - e) x`, 0,
+where it is `e/2`. It now rewrites only the whole expression, whose limit that rewrite keeps. And Gruntz's algorithm read
+a constant term its series had not been carried far enough to see as 0: `x^2 ln(1 + 1/x) - x` was known only to `w^0`
+once its `w^(-1)` terms cancelled, so its exponential was 1, and `(1 + 1/x)^(x^2) / e^x` at `+oo` was 1 where it is
+`e^(-1/2)`. A series now keeps only the terms it knows, and a part whose result falls short is expanded further, which
+also answers limits the series used to give up on, as `(Shi(x) - x) / x^3` at 0 from the right, `1/18`. The floor of a
+power tending to `e`, which the rewrite inside the expression used to answer, is now read as real by its structure:
+`floor((1 + 1/x)^x)` at `+oo` is `2`, as before. Values by mpmath at 80 digits. Measured on master `409d68805` and on this branch
+([#2706](https://github.com/asc-community/AngouriMath/issues/2706)).
+
+| `.Limit(x, ...)` | Was (`409d68805`) | Now |
+|---|---|---|
+| `(1 + 1/x)^(x^2) / exp(x)`, `(1 - 1/x)^(x^2) exp(x)`, `exp(x^2 ln(1 + 1/x) - x)` at `+oo` or `-oo` | `1` | `e^(-1/2)` |
+| `(1 + 2/x)^(x^2) / exp(2x)` at `+oo` or `-oo` | `1` | `e^(-2)` |
+| `(x/(x + 1))^(x^2) exp(x)`, `(1 + 1/x + 1/x^2)^(x^2) / exp(x)` at `+oo` or `-oo` | `e` | `e^(1/2)` |
+| `(e - (1 + 1/x)^x) x` at `+oo` | `0` | `e/2` |
+| `x ((1 + 1/x)^x - e)` at `+oo` | `0` | `-e/2` |
+| `x ln((1 + 1/x)^x / e)` at `+oo` | `0` | `-1/2` |
+| `((1 + x)^(1/x) - e) / x` at 0, from either side or both | `0` | `-e/2` |
+| `(1 + x)^(1/x^2) / exp(1/x)`, `((1 + x)^(1/x) / e)^(1/x)` at 0 | `1` | `e^(-1/2)` |
+| `(1 + x + x^2)^(1/x^2) / exp(1/x)` at 0 | `e` | `e^(1/2)` |
+| `(1 + x)^(1/x^3) / exp(1/x^2 - 1/(2x))` at 0 from the right; from the left | `+oo`; `0` | `e^(1/3)` |
+| `(1 + x)^(1/x^2) (1 - x)^(1/x^2)` at 0 | `1` | `e^(-1)` |
+| `((1 + x)^(1/x) (1 - x)^(1/x) - 1) / x^2` at 0 | `0` | `NaN` (`-oo` from the right, `+oo` from the left) |
+| `cos(x)^(1/x^4) exp(1/(2 x^2))` at 0 | unevaluated | `e^(-1/12)` |
+| `1 / log(x^2, cos(x))` at 0 | unevaluated | `+oo` |
+| `(Shi(x) - x) / x^3` at 0 from the right | unevaluated | `1/18` |
+| `(sin(x) - (x - x^3/6 + x^5/120)) / x^5` at 0 from the right | unevaluated | `0` |
+
### A two-sided limit is NaN only where its sides say so
**Not silent: a wrong answer becomes an unevaluated limit.** A two-sided limit came back `NaN`, the claim that it does
diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Gruntz/AsymptoticSeries.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Gruntz/AsymptoticSeries.cs
index 6fa42a318..49bef522c 100644
--- a/Sources/AngouriMath/Functions/Continuous/Limits/Gruntz/AsymptoticSeries.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Limits/Gruntz/AsymptoticSeries.cs
@@ -174,6 +174,12 @@ internal AsymptoticSeries Multiply(AsymptoticSeries other)
private static SeriesExponent Min(SeriesExponent a, SeriesExponent b) => a.CompareTo(b) <= 0 ? a : b;
+ ///
+ /// Whether the term at w^0 is known: a series truncated at or below w^0 says nothing about it, and
+ /// taking a missing constant for 0 there reads a series that cancelled down to its order as one that vanishes.
+ ///
+ private bool KnowsItsConstant => Order.CompareTo(SeriesExponent.Zero) > 0;
+
///
/// The series divided by its own leading term, which leaves a series starting at 1.
///
@@ -229,9 +235,12 @@ internal AsymptoticSeries WithoutConstant()
break;
sum = sum.Add(term);
}
- return sum.WithOrder(requested).Multiply(Monomial((1 / coefficient).InnerSimplified, power.Negate()));
+ return sum.WithOrder(Min(requested, rest.Order)).Multiply(Monomial((1 / coefficient).InnerSimplified, power.Negate()));
}
+ /// How many times over a part may be expanded again to reach the order asked of it.
+ private const int MaxOrderRaises = 3;
+
/// How many terms of a geometric, exponential or logarithmic series to take.
private const int MaxExpansionTerms = 24;
@@ -243,6 +252,8 @@ internal AsymptoticSeries WithoutConstant()
///
internal AsymptoticSeries? Exponentiate(SeriesExponent requested)
{
+ if (!KnowsItsConstant)
+ return null;
var constant = Terms.TryGetValue(SeriesExponent.Zero, out var atZero) ? atZero : Integer.Zero;
var rest = WithoutConstant();
if (rest.LeadingTerm() is var (_, least) && least.CompareTo(SeriesExponent.Zero) <= 0)
@@ -259,7 +270,7 @@ internal AsymptoticSeries WithoutConstant()
break;
sum = sum.Add(term);
}
- return sum.WithOrder(requested).Multiply(Constant(scale));
+ return sum.WithOrder(Min(requested, rest.Order)).Multiply(Constant(scale));
}
///
@@ -282,6 +293,8 @@ internal AsymptoticSeries WithoutConstant()
///
internal AsymptoticSeries? Through(Func function, SeriesExponent requested, Func? derivativeAtZero = null)
{
+ if (!KnowsItsConstant)
+ return null;
var constant = Terms.TryGetValue(SeriesExponent.Zero, out var atZero) ? atZero : Integer.Zero;
var rest = WithoutConstant();
if (rest.LeadingTerm() is var (_, least) && least.CompareTo(SeriesExponent.Zero) <= 0)
@@ -339,7 +352,7 @@ internal AsymptoticSeries WithoutConstant()
break;
sum = sum.Add(term.Multiply(Constant(Rational.Create(i % 2 == 1 ? 1 : -1, i))));
}
- return sum.WithOrder(requested);
+ return sum.WithOrder(Min(requested, rest.Order));
}
///
@@ -363,8 +376,7 @@ internal AsymptoticSeries WithoutConstant()
case Mulf(var left, var right):
return Both(left, right, (a, b) => a.Multiply(b));
case Divf(var left, var right):
- return Expand(right, w, logarithmOfW, order) is { } divisor
- && divisor.Invert(order) is { } inverted
+ return Raised(right, (divisor, inner) => divisor.Invert(inner)) is { } inverted
&& Expand(left, w, logarithmOfW, inverted.Order) is { } dividend
? dividend.Multiply(inverted)
: null;
@@ -376,7 +388,7 @@ internal AsymptoticSeries WithoutConstant()
&& SeriesExponent.Of(power) is { } exponent:
return Monomial(1, exponent);
case Powf(var @base, var power) when @base == MathS.e:
- return Expand(power, w, logarithmOfW, order)?.Exponentiate(order);
+ return Raised(power, (series, _) => series.Exponentiate(order));
case Powf(var @base, var power) when !power.ContainsNode(w):
return RaiseToConstant(@base, power, w, logarithmOfW, order);
case Powf(var @base, var power):
@@ -384,44 +396,75 @@ internal AsymptoticSeries WithoutConstant()
// between them can expand.
return Expand(MathS.Pow(MathS.e, power * MathS.Ln(@base)), w, logarithmOfW, order);
case Logf(var @base, var antilog) when !@base.ContainsNode(w):
- return Expand(antilog, w, logarithmOfW, order)?.Logarithm(logarithmOfW, order) is { } logarithm
+ return Raised(antilog, (antilogarithm, _) => antilogarithm.Logarithm(logarithmOfW, order)) is { } logarithm
? logarithm.Multiply(Constant((1 / MathS.Ln(@base)).InnerSimplified))
: null;
// Only reached for a function Gruntz.Mrv has found analytic where its argument ends up.
// https://github.com/asc-community/AngouriMath/issues/2690
case Sinf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Sin, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Sin, order));
case Cosf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Cos, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Cos, order));
case Tanf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Tan, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Tan, order));
case Cotanf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Cotan, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Cotan, order));
case Secantf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Sec, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Sec, order));
case Cosecantf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Cosec, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Cosec, order));
case Arctanf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Arctan, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Arctan, order));
case Erff(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Erf, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Erf, order));
case Erfcf(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Erfc, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Erfc, order));
case Erfif(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Erfi, order);
+ return Raised(argument, (series, _) => series.Through(MathS.Erfi, order));
// Si(t) = sum (-1)^j t^(2j+1) / ((2j+1) (2j+1)!) and Shi(t) the same without the signs, so the k-th
// derivative at 0 is 0 for an even k and (-1)^j / k, or 1 / k, for k = 2j + 1.
// https://github.com/asc-community/AngouriMath/issues/2694
case Sif(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Si, order,
- k => k % 2 == 0 ? Integer.Zero : Rational.Create(k % 4 == 1 ? 1 : -1, k));
+ return Raised(argument, (series, _) => series.Through(MathS.Si, order,
+ k => k % 2 == 0 ? Integer.Zero : Rational.Create(k % 4 == 1 ? 1 : -1, k)));
case Shif(var argument):
- return Expand(argument, w, logarithmOfW, order)?.Through(MathS.Shi, order,
- k => k % 2 == 0 ? Integer.Zero : Rational.Create(1, k));
+ return Raised(argument, (series, _) => series.Through(MathS.Shi, order,
+ k => k % 2 == 0 ? Integer.Zero : Rational.Create(1, k)));
default:
return null;
}
+ // An operation on a part's series, the part carried further where the result falls short of the order asked
+ // of it. A product with a negative power of w cuts the order of a series short, and so do dividing by a
+ // series and taking its logarithm, which take its leading term out: w^(-2) ln(1 + w) - w^(-1) asked to w^2
+ // comes back known only to w^0, its w^(-1) terms cancelled, and its exponential needs the constant, -1/2,
+ // which is there once the logarithm is carried to w^3. Read as 0, it made (1 + 1/x)^(x^2) / e^x at +oo 1,
+ // where it is e^(-1/2). A result that is still short is kept: it is right as far as it goes, and the caller
+ // raises the order where it needs a term past it.
+ // https://github.com/asc-community/AngouriMath/issues/2706
+ AsymptoticSeries? Raised(Entity part, Func operation)
+ {
+ var inner = order;
+ AsymptoticSeries? best = null;
+ for (var attempt = 0; attempt <= MaxOrderRaises; attempt++)
+ {
+ if (Expand(part, w, logarithmOfW, inner) is not { } expanded)
+ return best;
+ if (operation(expanded, inner) is { } result)
+ {
+ best = result;
+ if (result.Order.CompareTo(order) >= 0)
+ return result;
+ inner = inner.Add(order.Subtract(result.Order));
+ }
+ else
+ // Nothing to read at this order -- a constant that is not known, or a leading term that
+ // cancelled -- so the part is carried twice as far.
+ inner = inner.Add(order);
+ }
+ return best;
+ }
+
AsymptoticSeries? Both(Entity left, Entity right, Func combine)
=> Expand(left, w, logarithmOfW, order) is { } a && Expand(right, w, logarithmOfW, order) is { } b
? combine(a, b)
@@ -463,7 +506,7 @@ internal AsymptoticSeries WithoutConstant()
break;
sum = sum.Add(term);
}
- sum = sum.WithOrder(requested);
+ sum = sum.WithOrder(Min(requested, rest.Order));
var scaled = MathS.Pow(coefficient, power).InnerSimplified;
return sum.Multiply(Monomial(scaled, leading.Scale(wanted)));
}
diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs
index ed08bf760..f058d2089 100644
--- a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Limit.Classes.cs
@@ -1167,7 +1167,10 @@ Entity WithTheImaginaryStep(Entity realAnswer)
// imaginary part's side, or to declining, never to an answer of its own.
Entity? ImaginaryStep()
{
- if (Functions.TreeAnalyzer.IsRealValued(argument, x) || IsRealJustOff())
+ // Decided by structure as well, where the sample has no value: (1 + 1/x)^x at 10^6 is a rational power
+ // too large to evaluate, and floor of it at +oo, which is 2, was left unevaluated.
+ // https://github.com/asc-community/AngouriMath/issues/2706
+ if (Functions.TreeAnalyzer.IsRealValued(argument, x) || IsRealOnTheApproach(argument, x, dist) || IsRealJustOff())
return Integer.Zero;
return SignNear(MathS.Im(argument), x, dist, side) is { } arrivesFrom && arrivesFrom != 0
? atAJump(Integer.Zero, arrivesFrom)
diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs
index adebd6b1c..11978f1e2 100644
--- a/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Limits/Solvers/Solvers.Definition.cs
@@ -93,7 +93,7 @@ private static Entity AsAPowerOfTheVariable(Entity node, Variable x)
secondRemarkableRereads++;
try
{
- if (expr.Replace(node => ApplySecondRemarkable(node, x, Real.PositiveInfinity)) is var reread
+ if (ApplySecondRemarkable(expr, x, Real.PositiveInfinity) is var reread
&& reread != expr
&& ComputeLimit(reread, x, Real.PositiveInfinity) is { } byRemarkable
&& byRemarkable.Evaled != MathS.NaN)
@@ -818,7 +818,7 @@ node is Derivativef(var expression, Variable variable, var iterations) && iterat
expr = expr.Replace(a => TrivialTrigonometricReplacement(a, x));
expr = ApplyTrivialTransformations(expr, x, dest, side, (_, exprLim) => exprLim);
expr = ApplyFirstRemarkableOverFactors(expr, x, dest, side);
- expr = expr.Replace(c => ApplySecondRemarkable(c, x, dest));
+ expr = ApplySecondRemarkable(expr, x, dest);
// A tangent is a quotient as much as a cosecant is a reciprocal, and leaving it
// written as one function makes it opaque to everything that reads quotients --
// including the split that puts a difference of fractions over one denominator,
diff --git a/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs b/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs
index 1b10ceae0..3582ce5cc 100644
--- a/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs
@@ -980,7 +980,7 @@ internal static bool TakesItsValueOnACut(Entity node, Variable x, Entity dest)
/// 's, and unlisted is not real, which costs
/// coverage and never correctness.
///
- private static bool IsRealOnTheApproach(Entity expr, Variable x, Entity dest)
+ internal static bool IsRealOnTheApproach(Entity expr, Variable x, Entity dest)
{
if (dest.Evaled is not Real)
return false;
diff --git a/Sources/Tests/UnitTests/Calculus/AnUndecidedSideLeavesTheLimitUnevaluatedTest.cs b/Sources/Tests/UnitTests/Calculus/AnUndecidedSideLeavesTheLimitUnevaluatedTest.cs
index f6d4e37e4..09ec44e5e 100644
--- a/Sources/Tests/UnitTests/Calculus/AnUndecidedSideLeavesTheLimitUnevaluatedTest.cs
+++ b/Sources/Tests/UnitTests/Calculus/AnUndecidedSideLeavesTheLimitUnevaluatedTest.cs
@@ -24,10 +24,10 @@ public sealed class AnUndecidedSideLeavesTheLimitUnevaluatedTest
// in AStepOfAnUnboundedArgumentTimesAVanishingFactorTest.
[InlineData("floor(1/x) / floor(2/x)")]
// A side that stops at 0 / 0, or at c / 0, of an expression real beside the point is undecided too:
- // erf(abs(x)) / x^4 is +oo from each side, 1 / log(x^2, cos(x)) is +oo, abs(x)^erf(x) is 1.
+ // erf(abs(x)) / x^4 is +oo from each side, abs(x)^erf(x) is 1. 1 / log(x^2, cos(x)), +oo, is answered now, and is
+ // pinned in TheCorrectionToTheSecondRemarkableLimitTest.
[InlineData("erf(abs(x)) / x^4")]
[InlineData("erf(abs(x)) / (x^3 * sinh(x))")]
- [InlineData("1 / log(x^2, cos(x))")]
[InlineData("abs(x)^erf(x)")]
[InlineData("tan(1/2 + x) + abs(x)^erf(x)")]
[InlineData("1 / (x * arccot(x))")]
diff --git a/Sources/Tests/UnitTests/Calculus/TheCorrectionToTheSecondRemarkableLimitTest.cs b/Sources/Tests/UnitTests/Calculus/TheCorrectionToTheSecondRemarkableLimitTest.cs
new file mode 100644
index 000000000..b969e80da
--- /dev/null
+++ b/Sources/Tests/UnitTests/Calculus/TheCorrectionToTheSecondRemarkableLimitTest.cs
@@ -0,0 +1,94 @@
+//
+// 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
+{
+ ///
+ /// (1 + u)^(1/u) tends to e with an error of order u, and where that error is multiplied by something that grows the
+ /// limit is not the one of e put in its place: (1 + 1/x)^(x^2) / e^x at +oo is e^(-1/2), since x^2 ln(1 + 1/x) - x
+ /// tends to -1/2, and it was 1. Values by mpmath at 80 digits.
+ /// https://github.com/asc-community/AngouriMath/issues/2706
+ ///
+ [Trait("Area", "Calculus")]
+ public sealed class TheCorrectionToTheSecondRemarkableLimitTest
+ {
+ private static void LimitIs(string input, Entity destination, ApproachFrom side, string expected)
+ => Assert.Equal(MathS.FromString(expected).Simplify(),
+ MathS.FromString(input).Limit("x", destination, side).Simplify());
+
+ // Gruntz's algorithm took a constant it had not carried the series far enough to see for 0: the exponent
+ // x^2 ln(1 + 1/x) - x came back known only to w^0 once its w^(-1) terms cancelled, and its exponential was 1.
+ [Theory]
+ [InlineData("(1 + 1/x)^(x^2)/exp(x)", "e^(-1/2)")]
+ [InlineData("exp(x^2*ln(1 + 1/x) - x)", "e^(-1/2)")]
+ [InlineData("(1 + 2/x)^(x^2)/exp(2*x)", "e^(-2)")]
+ [InlineData("(1 - 1/x)^(x^2)*exp(x)", "e^(-1/2)")]
+ [InlineData("(x/(x + 1))^(x^2)*exp(x)", "e^(1/2)")]
+ [InlineData("(1 + 1/x + 1/x^2)^(x^2)/exp(x)", "e^(1/2)")]
+ [InlineData("(1 + 1/x)^(x^2)*(1 - 1/x)^(x^2)", "e^(-1)")]
+ [InlineData("cos(1/x)^(x^4)*exp(x^2/2)", "e^(-1/12)")]
+ public void Issue2706_AtInfinity(string input, string expected)
+ {
+ LimitIs(input, Entity.Number.Real.PositiveInfinity, ApproachFrom.BothSides, expected);
+ if (input != "cos(1/x)^(x^4)*exp(x^2/2)")
+ LimitIs(input, Entity.Number.Real.NegativeInfinity, ApproachFrom.BothSides, expected);
+ }
+
+ // The second remarkable limit wrote e for (1 + 1/x)^x inside a product, whose other factor grows: the error of
+ // that is -e/(2x), and (e - (1 + 1/x)^x) x was 0.
+ [Theory]
+ [InlineData("(e - (1 + 1/x)^x)*x", "e/2")]
+ [InlineData("x*((1 + 1/x)^x - e)", "-e/2")]
+ [InlineData("x^2*((1 + 1/x)^x - e + e/(2*x))", "11/24*e")]
+ [InlineData("x*ln((1 + 1/x)^x/e)", "-1/2")]
+ [InlineData("(1 + 1/x)^(x^2)*exp(-x) + 1", "e^(-1/2) + 1")]
+ public void Issue2706_AProductWithAGrowingFactor(string input, string expected)
+ => LimitIs(input, Entity.Number.Real.PositiveInfinity, ApproachFrom.BothSides, expected);
+
+ [Theory]
+ [InlineData("((1 + x)^(1/x) - e)/x", "-e/2")]
+ [InlineData("(e - (1 + x)^(1/x))/ln(1 + x)", "e/2")]
+ [InlineData("(1 + x)^(1/x^2)/exp(1/x)", "e^(-1/2)")]
+ [InlineData("(1 + x + x^2)^(1/x^2)/exp(1/x)", "e^(1/2)")]
+ [InlineData("(1 + x)^(1/x^2)*(1 - x)^(1/x^2)", "e^(-1)")]
+ [InlineData("((1 + x)^(1/x)/e)^(1/x)", "e^(-1/2)")]
+ public void Issue2706_AtZero(string input, string expected)
+ {
+ LimitIs(input, 0, ApproachFrom.BothSides, expected);
+ LimitIs(input, 0, ApproachFrom.Left, expected);
+ LimitIs(input, 0, ApproachFrom.Right, expected);
+ }
+
+ // ln(1 + x)/x^3 - 1/x^2 + 1/(2x) tends to 1/3 from either side.
+ [Fact]
+ public void Issue2706_AThirdOrderCorrection()
+ => LimitIs("(1 + x)^(1/x^3)/exp(1/x^2 - 1/(2*x))", 0, ApproachFrom.Right, "e^(1/3)");
+
+ // The floor of a power tending to e, which is not real to the evaluation at 10^6: (1 + 1/x)^x there is a
+ // rational power too large to take. It was read as e^(x (1/x)) inside the floor, and left unevaluated once not.
+ [Theory]
+ [InlineData("floor((1 + 1/x)^x)", "2")]
+ [InlineData("floor(2*(1 + 1/x)^x)", "5")]
+ [InlineData("ceil((1 - 1/x)^x)", "1")]
+ public void Issue2706_AStepOfAPowerTendingToE(string input, string expected)
+ => LimitIs(input, Entity.Number.Real.PositiveInfinity, ApproachFrom.BothSides, expected);
+
+ // ln(x^2) / ln(cos(x)), whose divisor is -x^2/2 + O(x^4): the series of its reciprocal is carried past the
+ // term the leading one leaves. It was left unevaluated.
+ [Fact]
+ public void Issue2706_ALogarithmOverALogarithmOfAFunctionTendingToOne()
+ => LimitIs("1 / log(x^2, cos(x))", 0, ApproachFrom.BothSides, "+oo");
+
+ // e^(-x) (1 + x)^(1/x) - 1 is -3x/2 + O(x^2), so over x^2 it has no limit from both sides.
+ [Fact]
+ public void Issue2706_AFirstOrderTermOverASquareHasNoLimit()
+ => Assert.Equal(MathS.NaN, MathS.FromString("((1 + x)^(1/x)*(1 - x)^(1/x) - 1)/x^2").Limit("x", 0));
+ }
+}