$F_k(a_1,b_1,c_1;a_2,b_2,c_2)=\int_0^k\frac{a_1x^2+b_1x+c_1}{a_2x^2+b_2x+c_2}\mathrm{d}x$ I would like to know a general closed form for
$$J=F_k(a_1,b_1,c_1;a_2,b_2,c_2)=\int_0^k\frac{a_1x^2+b_1x+c_1}{a_2x^2+b_2x+c_2}\mathrm{d}x$$
Where $k>0$, $4a_1c_1-b_1^2<0$, and $4a_2c_2-b_2^2<0$. I encounter forms of the integral all the time and I thought it would be beneficial to finally put that to rest. I already know that 
$$I_k(a,b,c)=\int_0^k\frac{\mathrm{d}x}{ax^2+bx+c}=\frac1g\bigg[\arctan\bigg(\frac{2ak+b}g\bigg)-\arctan\bigg(\frac bg\bigg)\bigg]$$
where $g=\sqrt{4ac-b^2}$
Hence we have that $$J=a_1\int_0^k\frac{x^2}{a_2x^2+b_2x+c_2}\mathrm{d}x+b_1\int_0^k\frac{x}{a_2x^2+b_2x+c_2}\mathrm{d}x+c_1I_k(a_2,b_2,c_2)$$
So really one must focus on the integrals 
$$H=\int_0^k\frac{x^2}{a_2x^2+b_2x+c_2}\mathrm{d}x$$
$$W=\int_0^k\frac{x}{a_2x^2+b_2x+c_2}\mathrm{d}x$$
They don't seem especially hard, but I just keep getting lost in the algebra with the constants. Could I have a bit of help? Thanks.
 A: While it's natural to compute the integrals $$\int_0^k \frac{x^n \,dx}{a_2 x^2 + b_2 x + c_2},$$
it's somewhat more efficient to decompose the integral in a different way. (Herein we suppose $a_2 \neq 0$; the case $a_2 = 0$ is easier.)
Notice that we can write the numerator of the integrand as
$$\frac{a_1}{a_2}(a_2 x^2 + b_2 x + c_2) + B x + C$$
for some constants $B, C$ (that we can write explicitly in terms of the $a_i, b_i, c_i$), so we can write the integral as
$$\int_0^k \frac{a_1 x^2 + b_1 x + c_1}{a_2 x^2 + b_2 x + c_2} dx
= k \cdot \frac{a_1}{a_2} + \color{#df0000}{\int_0^k \frac{B x + C}{a_2 x^2 + b_2 x + c_2} dx} .$$
Now, with a view toward applying the substitution $$u = a_2 x^2 + b_2 x + c_2, \qquad du = 2 a_2 x + b_2 ,$$
we can write the numerator of the second integrand as $$B x + C = \frac{B}{2 a_2} (2 a_2 x + b_2) + D$$
for some constant $D$ (that again we can write explicitly). So, the integral on the right-hand side is
$$\color{#df0000}{\int_0^k \frac{B x + C}{a_2 x^2 + b_2 x + c_2} dx} = \frac{B}{2 a_2} \int_0^k \frac{2 a_2 x + b_2}{a_2 x^2 + b_2 x + c} dx + D \int_0^k \frac{dx}{a_2 x^2 + b_2 x + c_2} .$$ Rewriting the first term on the r.h.s. with the above substitution gives
$$\frac{B}{2 a_2} \int_{c_2}^{a_2 k^2 + b_2 k + c_2} \frac{du}{u},$$ and the second integral on the r.h.s. is the quantity you denoted $I_k(a, b, c)$, for which you've already found an expression.
A: The process should work the same way with the integral you call $I$. Pull out $a$ in the denominator, complete the square, substitute $u = x + b/2a$, pull out $(4ac-b^{2})/4a^{2}$ from denominator and substitute $y = 2au/\sqrt{4ac-b^{2}}$), and then you should arrive at three elementary integrals
$$ \int\frac{x^{2}\,\mathrm{d}x}{x^{2}+1} \quad\quad \int\frac{x\,\mathrm{d}x}{x^{2}+1} \quad\quad \int\frac{\mathrm{d}x}{x^{2}+1}.$$
As a result of the first substitution, you should have all three of the integrals above to evaluate for integral $H$, and two of them for integral $W$.
A: Here is a fairly
simple-minded first step.
$\begin{array}\\
H
&=\int_0^k\dfrac{x^2}{a_2x^2+b_2x+c_2}dx\\
&=\dfrac1{a_2}\int_0^k\dfrac{x^2}{x^2+b^*_2x+c_2^*}dx\\
&=\dfrac1{a_2}\int_0^k\dfrac{x^2+b^*_2x+c_2^*-(b^*_2x+c_2^*)}{x^2+b^*_2x+c_2^*}dx\\
&=\dfrac1{a_2}\int_0^k\left(1-\dfrac{b^*_2x+c_2^*}{x^2+b^*_2x+c_2^*}\right)dx\\
&=\dfrac1{a_2}\left(k-\int_0^k\left(\dfrac{b^*_2x}{x^2+b^*_2x+c_2^*}\right)dx-\int_0^k\left(\dfrac{c_2^*}{x^2+b^*_2x+c_2^*}\right)dx\right)\\
\end{array}
$
So $H$ reduces to
the other two,
one of which you know.
