Repository navigation
Commit a2c29b2
authored
* Integrate a quotient whose numerator is not constant (#233)
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.
* Split a rational function at a rational root of its denominator
A linear or quadratic denominator was answered in one piece, but nothing read
anything above that, so 1/(x^3 + 1) had no antiderivative at all. It is on the
list of what is missing in
#233.
The decomposition is done a step at a time rather than in full, because a step
is all that is needed: what is left over is a smaller problem of the same kind,
and by the time its denominator is a quadratic there is already a rule for it.
1/(x^3 + 1) splits at the root -1 into (1/3)/(x + 1) and
(2 - x)/(3(x^2 - x + 1)), and the second is a linear numerator over a quadratic,
which the previous commit reads as it stands. Each step takes a degree off the
denominator, so it ends.
The coefficient is Heaviside's -- at the root every other term of the
decomposition is finite, so A = N(r)/Q(r) -- and what is left, N - A*Q, then has
that root by construction and divides exactly. All of it on the exact ratios,
reusing the rational root search already here for factoring.
Rational roots only, and simple ones. A denominator with no rational root, such
as x^4 + 1, and one whose root repeats, which would need a term over the square
as well, are both left unevaluated rather than answered wrongly. A denominator
below degree three is left to the rules that answer it in one piece.
Ten integrals gained, each checked by differentiating back:
1/(x^3 + 1), x/(x^3 + 1), 1/(x^3 - x), 1/(x^3 + x), 1/(x^4 - 1), x/(x^4 - 1),
(x^2 + 1)/(x^3 - x), 1/((x - 1)(x - 2)(x - 3)) whether written factored or
multiplied out, and (x + 1)/(x^3 - x^2 - 2x).
21 tests, 10 of which fail without the change. 4038 in all, 127 F#, corpus
105/117 with the partial fraction category at 80% from 60% and nothing wrong,
in error or timing out. 1320 property checks.
1 parent 9444691 commit a2c29b2
4 files changed
Lines changed: 204 additions & 2 deletions
File tree
- Sources
- AngouriMath/Functions
- Continuous/Integration
- Simplification
- Tests/UnitTests/Calculus
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
26 | 50 | | |
27 | 51 | | |
28 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
108 | 195 | | |
109 | 196 | | |
110 | 197 | | |
111 | 198 | | |
112 | 199 | | |
113 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
114 | 205 | | |
115 | 206 | | |
116 | 207 | | |
117 | 208 | | |
118 | | - | |
| 209 | + | |
119 | 210 | | |
120 | 211 | | |
121 | 212 | | |
122 | | - | |
| 213 | + | |
123 | 214 | | |
124 | 215 | | |
125 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments