Ostrogradsky method is in general formula $$\int \frac{P(x)}{Q(x)}=\frac{P_1(x)}{Q_1(x)}+\int \frac{p(x)}{q(x)}dx$$
Where $\frac{P(x)}{Q(x)}$ is a simplest rational function; $q(x)$ is a polynomial with all the roots in $Q(x)$ but with only multiplicity $1$. $Q_1(x)=\frac{Q(x)}{q(x)}$
I would like to ask, how to prove this formula?
Given that $$\frac{P(x)}{Q(x)}=\sum_{j=1}^l\sum_{k=1}^{k_j}\left(\frac{a_{jk}}{(x-x_j)^k}\right)+\sum_{j=1}^n\sum_{k=1}^{m_j}\frac{b_{jk}x+c_{jk}}{(x^2+p_jx+q_j)^k}$$
Where $p(x)$ is a polynomial that only occurs when $\deg P(x)\ge \deg Q(x)$, and $a_{jk},b_{jk},c_{jk}$ are uniquely determined real numbers. and
$$Q(x)=(x-x_1)^{k_1}\cdots (x-x_l)^{k_l}(x^2+p_1x+q_1)^{m_1}\cdots (x^2+p_n x+q_n)^{m_n}$$
This is a problem from Zorich's Mathematical Analysis Differentiation chapter that I could not solve, and it is from the section antiderivatives.
I have tried using the algebra formula given, but it doesn't seem to work.