I need to evaluate an indefinite integral of the form $$I=\int\frac{x^5+2ax^3+a^2x-4a}{x^7+ax^5+2ax^4}dx=\int\frac{x^5+2ax^3+a^2x-4a}{x^4(x^3+ax+2a)}dx$$ I tried to factor the denominator to solve the integral as a partial fraction as follows: $$\frac{x^5+2ax^3+a^2x-4a}{x^4(x^3+ax+2a)}=\frac{A_1}{x}+\frac{A_2}{x^2}+\frac{A_3}{x^3}+\frac{A_4}{x^4}+\frac{A_5x^2+A_6x+A_7}{x^3+ax+2a}$$ I am doubtful about the last term of the above equation and I am not sure whether I am doing it correctly. This is because in most of the texts I referred, the denominator always contain terms of the form $(ax^2+bx+c)^n$ and not any cubic polynomial.
I just need to know whether my approach is correct or not. If I am wrong, what is the correct approach of solving such an integral?
N.B.: No need to solve the integral. I am asking only to know the correct way of solving the integral.
Thanks in advance.
EDIT:
I tried to solve the integral using SageMath where the output obtained is as follows: $$\frac{{\left(a^{2} + 10 \, a + 8\right)} \log\left(x\right)}{8 \, a} - \frac{\int \frac{a^{3} + {\left(a^{2} + 10 \, a + 8\right)} x^{2} + 14 \, a^{2} - 2 \, {\left(a^{2} + 6 \, a\right)} x + 16 \, a}{x^{3} + a x + 2 \, a}\,{d x}}{8 \, a} + \frac{3 \, {\left(a + 2\right)} x^{2} - 3 \, {\left(a + 2\right)} x + 8}{12 \, x^{3}}$$ According to the manual of SageMath, this happens when an integral has no closed form. So, is there any way through which I can solve the integral?
To complete the integration we need the last term $$ \int \frac{a^{3} + {\left(a^{2} + 10 \, a + 8\right)} x^{2} + 14 \, a^{2} - 2 \, {\left(a^{2} + 6 \, a\right)} x + 16 \, a}{x^{3} + a x + 2 \, a}\,{d x} $$ Maple does it this way: $$ \int \!{\frac { \left( {a}^{2}+10\,a+8 \right) {x}^{2}-2\, \left( {a}^ {2}+6\,a \right) x+{a}^{3}+14\,{a}^{2}+16\,a}{{x}^{3}+ax+2\,a}} \,{\rm d}x\\= \sum{\frac { {{\it \lambda}}^{2}{a}^{2}+10\,{{ \it \lambda}}^{2}a-2\,{\it \lambda}\,{a}^{2}+{a}^{3}+8\,{{\it \lambda}}^{2}-12\,{ \it \lambda}\,a+14\,{a}^{2}+16\,a }{3\,{{\it \lambda}}^{2}+a}}\;\log \left( x-{\it \lambda} \right) $$ Where the sum $\displaystyle\sum$ is the sum of three terms, one for each (possibly complex) solution of $\lambda^3+2\lambda + 2a = 0$ . As I said in the comment, you surely don't want to write out those solutions $\lambda$ in terms of radicals.
But if you do, Maple can do it...
The three solutions of $\lambda^3+2\lambda + 2a = 0$ are $$ \lambda_1 = {\frac { \left( -27\,a+3\,\sqrt {3}\sqrt {{a}^{2} \left( 27+a \right) } \right) ^{2/3}-3\,a}{3\sqrt [3]{-27\,a+3\,\sqrt {3}\sqrt {{a }^{2} \left( 27+a \right) }}}}, \\ \lambda_2 = {\frac {i\sqrt {3} \left( -27\,a+3 \,\sqrt {3}\sqrt {{a}^{2} \left( 27+a \right) } \right) ^{2/3}+3\,i \sqrt {3}a- \left( -27\,a+3\,\sqrt {3}\sqrt {{a}^{2} \left( 27+a \right) } \right) ^{2/3}+3\,a}{6\sqrt [3]{-27\,a+3\,\sqrt {3}\sqrt {{a }^{2} \left( 27+a \right) }}}}, \\ \lambda_3 = -{\frac {i\sqrt {3} \left( -27\,a+ 3\,\sqrt {3}\sqrt {{a}^{2} \left( 27+a \right) } \right) ^{2/3}+3\,i \sqrt {3}a+ \left( -27\,a+3\,\sqrt {3}\sqrt {{a}^{2} \left( 27+a \right) } \right) ^{2/3}-3\,a}{6\sqrt [3]{-27\,a+3\,\sqrt {3}\sqrt {{a }^{2} \left( 27+a \right) }}}} $$