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
8 changes: 8 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ as `a - b = 0`, as a statement's own solve reads it: `"x + 1 = 3".Solve("x")` wa
of `x`, by parts, in gamma functions of `u`.
And of a whole `a <= 0` over a power of another linear, by parts, where what is left is an exponential over
linears.
- **Integrals in it.** `x^m F^(a + b x^n)` and `(c + d x)^m F^(a + b x)` are `-F^a x^(m + 1) z^(-s) gamma(s, z)/n`, with
`z = -b ln(F) x^n` and `s = (m + 1)/n`, where `s` is neither whole nor half a whole number, or is past 30, as
`x^31 e^(-x)` is, whose sum of 32 terms is `-gamma(32, x)` now. A definite integral of such an answer that is
undefined at a bound is left as written.
([#2075](https://github.com/asc-community/AngouriMath/issues/2075))

| Input | Was (2.6.0) | Now |
Expand All @@ -156,6 +160,10 @@ as `a - b = 0`, as a statement's own solve reads it: `"x + 1 = 3".Solve("x")` wa
| `"x^2*gamma(0, a*x)".ToEntity().Integrate("x")` | a `FunctionArgumentCountException` | `x ^ 3 / 3 * gamma(0, a * x) - 1 / (3 * a ^ 3) * 2 * e ^ (-a * x) * (1 + a * x + (a * x) ^ 2 / 2) + C` |
| `"x^m*gamma(n, b*x)".ToEntity().Integrate("x")` | a `FunctionArgumentCountException` | `(x ^ (m + 1) * gamma(n, b * x) - x ^ m * (b * x) ^ (-m) * gamma(n + m + 1, b * x) / b) / (m + 1) + C` |
| `"gamma(0, a + b*x)/(c + d*x)^2".ToEntity().Integrate("x")` | a `FunctionArgumentCountException` | `-gamma(0, a + b x)/(d (c + d x))` and two exponential integrals, of `a + b x` and of `b (c + d x)/d` |
| `"x^(1/3)*e^(-x)".ToEntity().Integrate("x")` | `integral(x ^ (1/3) * e ^ (-x), x)` | `-gamma(4/3, x) + C` |
| `"(c + d*x)^m*e^(a + b*x)".ToEntity().Integrate("x")` | `integral((c + d * x) ^ m * e ^ (a + b * x), x)` | `e ^ (a - b * c / d) * (c + d * x) ^ m * (-b * (c + d * x) / d) ^ (-m) * gamma(m + 1, -b * (c + d * x) / d) / b + C` |
| `"x^31*e^(-x)".ToEntity().Integrate("x")` | a sum of 32 terms, 6,172 characters | `-gamma(32, x) + C` |
| `"integral(e^(x^3), x, 0, 1)".ToEntity().Simplify()` | `integral(e ^ x ^ 3, x, 0, 1)` | `(gamma(1/3, -1) - (-2/3)!) / 3`, which is `1.3419044179774…` |

### Numerical equality is to half the evaluation's digits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ private static bool OnlyInsideTranscendentalFunctions(Entity expr, Entity.Variab
// And one with a polynomial in x beside something in its antiderivative: what parts
// leaves then has the power it took away, and asking it does not descend --
// `x erfc(a + b x)^2`, whose cofactor's antiderivative has `x erfc(a + b x)^2` in it.
// Nor one whose antiderivative is an incomplete gamma function of an argument that is not linear, which
// the remainder would hold: see TryIntegrateByPartsOnce. `(g + h x)^2 (a + b ln(c (d (e + f x)^p)^q))^n`
// went from a decline in three seconds to one in two minutes.
if (Integration.ComputeAsAQuestionOfItsOwn(rest, x, integrateByParts: true) is not { } antiderivative
|| HasAPolynomialFactorIn(antiderivative, x))
|| HasAPolynomialFactorIn(antiderivative, x) || IntroducesAnIncompleteGammaFunctionOfANonlinear(antiderivative, rest, x))
{
remainder.Add(term);
continue;
Expand Down Expand Up @@ -5166,6 +5169,9 @@ static Entity WithTheConstantMatchedTo(Entity antiderivative, Entity derivativeO
?? Integration.ComputeIndefiniteIntegral(toIntegrate, x, false);
if (integral is null) return null;
var differential = polynomialToDifferentiate.Differentiate(x);
// And the next round integrates what this one returned, which nothing does where that is an incomplete
// gamma function of an argument that is not linear: see TryIntegrateByPartsOnce.
if (!TreeAnalyzer.IsZero(differential) && IntroducesAnIncompleteGammaFunctionOfANonlinear(integral, toIntegrate, x)) return null;
var result = IntegrateByPartsPolynomial(differential, integral, x, currentRecursion + 1);
return (result is null) ? null : polynomialToDifferentiate * integral - result;
}
Expand Down Expand Up @@ -5194,6 +5200,12 @@ static Entity WithTheConstantMatchedTo(Entity antiderivative, Entity derivativeO
byThePolynomialsParts = integralOfU is not null;
}
if (integralOfU is null) return null;
// Not where the integral of u is an incomplete gamma function of an argument that is not linear, which u
// did not hold: the remainder holds it then, and nothing here integrates it. (a + b ln(c x^n))^p beside
// d + e ln(f x^r) integrates the power to gamma(p + 1, -(a + b ln(c x^n))/(b n)), and the search on its
// remainder sampled it three thousand times before declining, thirty-five seconds where it had been one.
// https://github.com/asc-community/AngouriMath/issues/2075
if (IntroducesAnIncompleteGammaFunctionOfANonlinear(integralOfU, u, x)) return null;

// Differentiate v
var derivativeOfV = v.Differentiate(x).InnerSimplified;
Expand Down Expand Up @@ -50047,6 +50059,23 @@ Entity Term(Entity? sum, Entity coefficient, int power)
/// </summary>
[System.ThreadStatic] private static bool askingTheTermsOfARemainder;

/// <summary>
/// Whether <paramref name="integral"/> holds an incomplete gamma function of an argument not linear in
/// <paramref name="x"/> where <paramref name="integrand"/> holds none.
/// </summary>
private static bool IntroducesAnIncompleteGammaFunctionOfANonlinear(Entity integral, Entity integrand, Variable x)
{
foreach (var node in integral.Nodes)
if (node is IncompleteGammaf { LowerLimit: var argument } && !TreeAnalyzer.TryGetPolyLinear(argument, x, out _, out _))
{
foreach (var written in integrand.Nodes)
if (written is IncompleteGammaf)
return false;
return true;
}
return false;
}

private static bool IsASpecialFunction(Entity node)
=> node is Entity.Erff or Entity.Erfcf or Entity.Erfif or Entity.Eif or Entity.Lif
or Entity.Sif or Entity.Cif or Entity.Shif or Entity.Chif;
Expand Down
Loading
Loading