Skip to content

Commit 16203aa

Browse files
A constant of integration is matched to a linear divisor with a symbol in it (#1642)
By parts against a polynomial chooses the polynomial's antiderivative so that what the other factor's derivative divides by divides it too: against x ln(1 + x) the antiderivative of x is (x^2 - 1)/2, and the remainder is a polynomial. That was done where the division left a number over, and a + b x leaves a symbol: x^2/2 over a + b x leaves a^2/(2 b^2), so x Shi(a + b x)^2 kept x^2/(a + b x) in its remainder and nothing read it. The antiderivative less its value at the root, -a/b, is divisible by the linear, and it is written now as the linear times the quotient, so that the linear cancels as written: x Shi(a + b x)^2 and x Ei(a + b x)^2 are two rounds of parts each. Measured on the Rubi corpus, master at 6c94652 and this change on it, run side by side: family 8 373 -> 376 of 420 (x Ei, x Shi and x Chi of a + b x, squared); family 2 544 of 650, the independent suites 1756 of 1814 and families 1 and 3 to 7 at five a file 800 of 897, on both. 0 wrong everywhere. Run alone, the three are 0 of 3 on master and 3 of 3 here; the fourth problem that moved, 2.3 #622, is 22 s unevaluated on both. The unit tests pass, 14,259. The performance gate passes on d480366e, which is this change on 6c94652: allocation is what the baseline says on all 19 gated benchmarks. SpecialFunctionsByPartsTest has two rows with a shifted argument, each differentiated back with its parameters pinned. Part of #1501. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8e0bb15 commit 16203aa

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,26 @@ no integrand without one changes: Rubi's independent suites and a sample of its
23152315
| `"Ei(b*x)^2".Integrate("x")` | `Ei * (b * x) ^ 3 / 3 / b + C`, with `Ei` a variable | an antiderivative in `Ei(b x)` and `Ei(2 b x)` |
23162316
| `"x*erf(b*x)^2".Integrate("x")` | `UnrecognizedFunctionParseException`: there is no function `erf` | an antiderivative in `erf(b x)` |
23172317

2318+
### A constant of integration is matched to a linear divisor with a symbol in it
2319+
2320+
By parts against a polynomial chooses the polynomial's antiderivative so that what the other
2321+
factor's derivative divides by divides it too, and that was done only where the division left a
2322+
number over. `a + b x` leaves a symbol: `x^2/2` over `a + b x` leaves `a^2/(2 b^2)`, so the
2323+
remainder of `x Shi(a + b x)^2` kept `x^2/(a + b x)` and nothing read it. The antiderivative less
2324+
its value at `-a/b` is taken now, written as `a + b x` times the quotient, so that the linear
2325+
cancels in the remainder ([#1501](https://github.com/asc-community/AngouriMath/issues/1501)).
2326+
`x Shi(a + b x)^2`, `x Chi(a + b x)^2` and `x Ei(a + b x)^2` are answered. An integrand holding one of
2327+
these functions had no reading in 2.5.0, which the entries for the functions themselves record, and
2328+
no integrand without one changes: Rubi's independent suites and a sample of its families 1 to 7
2329+
are answered alone as they were. Where by parts already answered a special function of `a + b x`
2330+
beside a power of `x`, the answer is written with the same constant: `x Ei(a + b x)` now reads
2331+
`Ei(a + b x) (a + b x)(x/(2b) - a/(2b^2)) - ...`, the same function as before.
2332+
2333+
| Input | Was (2.5.0) | Now |
2334+
|---|---|---|
2335+
| `"x*Shi(a+b*x)^2".Integrate("x")` | `a ^ 2 * Shi * x ^ 2 / 2 + a * b * 2 * Shi * x ^ 3 / 3 + b ^ 2 * Shi * x ^ 4 / 4 + C`, with `Shi` a variable | an antiderivative in `Shi(a + b x)` and `Ei(2 (a + b x))`, `Ei(-2 (a + b x))` |
2336+
| `"x*Ei(a+b*x)^2".Integrate("x")` | `a ^ 2 * Ei * x ^ 2 / 2 + a * b * 2 * Ei * x ^ 3 / 3 + b ^ 2 * Ei * x ^ 4 / 4 + C`, with `Ei` a variable | an antiderivative in `Ei(a + b x)` and `Ei(2 (a + b x))` |
2337+
23182338
### An exponential or a hyperbolic function over several linears is split into partial fractions over them
23192339

23202340
`e^x/(x (x + 1))` was left unevaluated, where `e^x/x` and `e^x/(x + 1)` were each answered with

‎Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,19 @@ static Entity WithTheConstantMatchedTo(Entity antiderivative, Entity derivativeO
16911691
&& Functions.SingleQuotient.Of(leftOver) is var (leftOverTop, _) && !leftOverTop.ContainsNode(x)
16921692
&& leftOverTop.Evaled is Number.Complex { IsZero: false } constant)
16931693
return (antiderivative + (-constant).Evaled).InnerSimplified;
1694+
// A linear divisor with a symbol in it, `a + b x`, leaves a symbol over, which the
1695+
// case above does not read: the antiderivative less its value at the root, -a/b, is
1696+
// divisible by the linear, and it is written as the linear times the quotient, so
1697+
// that the linear the derivative divides by cancels as written. `x Shi(a + b x)^2`
1698+
// is two rounds of parts that way, where with `x^2/2` the remainder kept
1699+
// `x^2/(a + b x)` and nothing read it.
1700+
// https://github.com/asc-community/AngouriMath/issues/1501
1701+
if (TreeAnalyzer.TryGetPolyLinear(divisors[0], x, out var slope, out var offset) && !TreeAnalyzer.IsZero(slope)
1702+
&& antiderivative.Substitute(x, (-offset / slope).InnerSimplified).InnerSimplified is var atTheRoot
1703+
&& !atTheRoot.ContainsNode(x) && !TreeAnalyzer.IsZero(atTheRoot)
1704+
&& TreeAnalyzer.PolynomialLongDivision((antiderivative - atTheRoot).Expand().InnerSimplified, divisors[0], genericCase: true, inTermsOf: x) is var (quotient, _)
1705+
&& !quotient.ContainsNode(MathS.NaN))
1706+
return divisors[0] * Functions.PartialFractions.Bare(quotient);
16941707
return antiderivative;
16951708
}
16961709

‎Sources/Tests/UnitTests/Calculus/SpecialFunctionsByPartsTest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,16 @@ public void BesideAPowerAndTheElementaryFactorOfItsDerivative(string integrand)
133133
[InlineData("Chi(b*x)^2")]
134134
public void ASquareIsTwoRoundsOfParts(string integrand)
135135
=> DifferentiatesBack(integrand, Parameters);
136+
137+
/// <summary>
138+
/// Of <c>a + b x</c>, the first round against <c>x</c> takes <c>x^2/2</c> less its value at
139+
/// <c>-a/b</c>, written as <c>a + b x</c> times the quotient, so the linear the derivative
140+
/// divides by cancels and what is left is the case above.
141+
/// </summary>
142+
[Theory]
143+
[InlineData("x*Shi(a + b*x)^2")]
144+
[InlineData("x*Ei(a + b*x)^2")]
145+
public void ASquareOfAShiftedArgumentIsTwoRoundsOfParts(string integrand)
146+
=> DifferentiatesBack(integrand, Parameters);
136147
}
137148
}

0 commit comments

Comments
 (0)