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
4 changes: 3 additions & 1 deletion BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ analytic where they are defined and is plainly not 0 at a point.
**Limits whose derivatives grew without bound under l'Hopital's rule are answered, where they did not
finish or were left unevaluated.** The rule differentiates the whole of each side, and the product rule
carries every factor beside the one it differentiates. Now a factor that tends to a finite number other
than 0 at an infinity is replaced by that number, as one continuous at a finite point already was, and a
than 0 at an infinity is replaced by that number, a quotient such as tanh(x) written through exponentials
being asked whole before its parts, as one continuous at a finite point already was, and a
polynomial written on both sides is divided out. The quotient of two logarithms does the same with the
four parts it is built from.

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"tanh(x) * x / (x + tanh(x))".ToEntity().Limit("x", "+oo")` | did not finish in 60 s | `1` |
| `"ln(tanh(x) + x) / ln((x - pi)^2)".ToEntity().Limit("x", "+oo")` | did not finish in 30 s | `1/2` |
| `"ln(tanh(x) + x) / ln(x - pi)".ToEntity().Limit("x", "+oo")` | did not finish in 30 s | `1` |
| `"ln(arctan(x) + x) / ln(x)".ToEntity().Limit("x", "+oo")` | unevaluated | `1` |
Expand Down
32 changes: 28 additions & 4 deletions Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,32 @@ private static (Entity Value, Entity Others) TakeOutContinuousFactors(Entity exp
return (Integer.One, expr);
Entity value = Integer.One, rest = Integer.One;
var any = false;
foreach (var factor in Mulf.LinearChildren(expr))
Gather(expr);
return any && rest.ContainsNode(x) ? (value.InnerSimplified, rest.InnerSimplified) : (Integer.One, expr);

// A quotient is asked whole before it is taken apart. tanh(x) written through exponentials
// is (e^(2x) - 1) / (e^(2x) + 1), which tends to 1 at +oo, while its two parts tend to +oo
// and to 0 and neither is taken out.
void Gather(Entity node)
{
if (node is Mulf(var left, var right))
{
Gather(left);
Gather(right);
}
else if (TakeOut(node))
return;
else if (node is Divf)
foreach (var factor in Mulf.LinearChildren(node))
{
if (!TakeOut(factor))
rest *= factor;
}
else
rest *= node;
}

bool TakeOut(Entity factor)
{
if (factor.ContainsNode(x)
&& !factor.Nodes.Any(static node => node is Floorf or Ceilf or Roundf or Signumf or Piecewise)
Expand All @@ -1665,11 +1690,10 @@ private static (Entity Value, Entity Others) TakeOutContinuousFactors(Entity exp
{
value *= there;
any = true;
return true;
}
else
rest *= factor;
return false;
}
return any && rest.ContainsNode(x) ? (value.InnerSimplified, rest.InnerSimplified) : (Integer.One, expr);
}

/// <summary>Whether <paramref name="node"/> is built from <paramref name="x"/> and real constants by sums, differences, products and positive whole powers.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public sealed class LhopitalKeepsTheDerivativesSmallTest
[InlineData("ln(tanh(x) + x) / ln(x)", "+oo", "1")]
[InlineData("ln(arctan(x) + x) / ln(x)", "+oo", "1")]
[InlineData("tanh(x) * x / (x + tanh(x))", "-oo", "-1")]
[InlineData("tanh(x) * x / (x + tanh(x))", "+oo", "1")]
[InlineData("(x - pi)^2 / ((x + tanh(x)) * (x - pi))", "+oo", "1")]
[InlineData("arctan(x) * x / (x + 1)", "+oo", "pi / 2")]
[InlineData("(x - 1)^2 * sin(x - 1) / ((x - 1)^3 * cos(x))", "1", "sec(1)")]
Expand Down
Loading