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