Primitive of x squared over a x + b squared by p x + q

Theorem

 * $\displaystyle \int \frac {x^2 \ \mathrm d x} {\left({a x + b}\right)^2 \left({p x + q}\right)} = \frac {b^2} {\left({b p - a q}\right) a^2 \left({a x + b}\right)} + \frac 1 {\left({b p - a q}\right)^2} \left({\frac {q^2} p \ln \left\vert{p x + q}\right\vert + \frac {b \left({b p - 2 a q}\right)} {a^2} \ln \left\vert{a x + b}\right\vert}\right) + C$

Proof
We have:

Therefore: