\[ \int \frac {\left (-q+2 p x^3\right ) \left (a q+b x+a p x^3\right ) \sqrt {q^2-2 p q x^2+2 p q x^3+p^2 x^6}}{x^4} \, dx \]
Optimal antiderivative \[ \frac {\sqrt {p^{2} x^{6}+2 p q \,x^{3}-2 p q \,x^{2}+q^{2}}\, \left (2 a \,p^{2} x^{6}+4 a p q \,x^{3}+3 b p \,x^{4}-4 a p q \,x^{2}+2 a \,q^{2}+3 b q x \right )}{6 x^{3}}+b p q \ln \left (x \right )-b p q \ln \left (q +p \,x^{3}+\sqrt {p^{2} x^{6}+2 p q \,x^{3}-2 p q \,x^{2}+q^{2}}\right ) \]
command
Integrate[((-q + 2*p*x^3)*(a*q + b*x + a*p*x^3)*Sqrt[q^2 - 2*p*q*x^2 + 2*p*q*x^3 + p^2*x^6])/x^4,x]
Mathematica 13.1 output
\[ \frac {\sqrt {q^2+2 p q (-1+x) x^2+p^2 x^6} \left (3 b x \left (q+p x^3\right )+2 a \left (q^2+2 p q (-1+x) x^2+p^2 x^6\right )\right )}{6 x^3}-b p q \tanh ^{-1}\left (\frac {\sqrt {q^2+2 p q (-1+x) x^2+p^2 x^6}}{q+p x^3}\right ) \]
Mathematica 12.3 output
\[ \int \frac {\left (-q+2 p x^3\right ) \left (a q+b x+a p x^3\right ) \sqrt {q^2-2 p q x^2+2 p q x^3+p^2 x^6}}{x^4} \, dx \]________________________________________________________________________________________