Repository navigation
Integrate a quotient whose numerator is not constant (#233) - #681
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #681 +/- ##
==========================================
- Coverage 80.99% 80.43% -0.57%
==========================================
Files 155 156 +1
Lines 13687 12934 -753
Branches 1957 2126 +169
==========================================
- Hits 11086 10403 -683
+ Misses 1990 1923 -67
+ Partials 611 608 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The table matched k/(ax^2 + bx + c) only when k did not mention x, so anything with a variable on top had no antiderivative at all: int x / (x^2 + 2x + 5) int (x + 3) / (x^2 + 3x + 2) int x / (x + 1) A linear numerator is a multiple of the denominator's derivative plus a constant: px + q = (p/2a)(2ax + b) + (q - pb/2a). The first part integrates to a logarithm and the second is the constant-numerator case that was already there, so this only needs the rewrite. The same rewrite one degree down turns (px + q)/(bx + c) into the constant p/b plus a remainder over the divisor. Both are guarded on the leading coefficient being a non-zero number, since the rewrite divides by it. A quadratic denominator with a vanishing quadratic term falls through to the linear arm rather than being divided by zero. Also 1/cos(u)^2 and 1/sin(u)^2, which are written that way at least as often as sec(u)^2 and csc(u)^2, and none of the four shapes was recognised. Corpus 88/117 -> 91/117: int:table and int:rational-quadratic reach 100%, and int:partial-fractions goes from 2 out of 5 to 3. 3901 unit tests and 127 F# tests pass, no wrong answers in the corpus, and the property checker's 1320 checks are clean. x^2/(x^4 + 1) and 1/(x^3 + 1) are still out of reach: both need the denominator factored first, which is a different piece of work.
f4d67d6 to
c15cf90
Compare
|
Rebased onto master now that #675 has landed. The two touch the same switch in |
Part of #233 (the partial-fractioning line), and a gap next to it.
What was missing
The table matched
k/(ax^2 + bx + c)only whenkdid not mentionx. Anything with a variable on top fell through every solver:What this adds
A linear numerator over a quadratic.
px + qis a multiple of the denominator's derivative plus a constant:The first part integrates to
ln|ax^2 + bx + c|and the second is the constant-numerator case thatIntegrateRationalQuadraticalready handles, including its split on the sign of the discriminant. So this is only the rewrite — no new closed forms and no new cases to get wrong.A linear numerator over a linear denominator, which is the same rewrite one degree down: the quotient is the constant
p/bplus a remainder over the divisor.Both are guarded on the leading coefficient being a non-zero number, since the rewrite divides by it. A quadratic denominator whose quadratic term vanishes falls through to the linear arm rather than being divided by zero, and there is a test for that.
1/cos(u)^2and1/sin(u)^2. Written that way at least as often assec(u)^2andcsc(u)^2, and none of the four shapes was recognised.secandcscthemselves already were.Verification
int:tableandint:rational-quadraticreach 100%;int:partial-fractionsgoes from 2 out of 5 to 3.Not covered
x^2/(x^4 + 1)and1/(x^3 + 1)— the two remainingint:partial-fractionsentries — still return unevaluated. Both need the denominator factored before the fractions can be split, andx^4 + 1factors only over the irrationals. That is a separate piece of work.