\[ \int \frac {(-2+(1+k) x) \left (1-(1+k) x+(a+k) x^2\right )}{x^2 \sqrt [3]{(1-x) x (1-k x)} \left (1-(1+k) x+(-b+k) x^2\right )} \, dx \]
Optimal antiderivative \[ \frac {3 \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {2}{3}}}{2 x^{2}}+\frac {\left (-\sqrt {3}\, a -b \sqrt {3}\right ) \arctan \left (\frac {\sqrt {3}\, b^{\frac {1}{3}} x}{b^{\frac {1}{3}} x +2 \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {1}{3}}}\right )}{b^{\frac {1}{3}}}+\frac {\left (a +b \right ) \ln \left (-b^{\frac {1}{3}} x +\left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {1}{3}}\right )}{b^{\frac {1}{3}}}+\frac {\left (-a -b \right ) \ln \left (b^{\frac {2}{3}} x^{2}+b^{\frac {1}{3}} x \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {1}{3}}+\left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {2}{3}}\right )}{2 b^{\frac {1}{3}}} \]
command
Integrate[((-2 + (1 + k)*x)*(1 - (1 + k)*x + (a + k)*x^2))/(x^2*((1 - x)*x*(1 - k*x))^(1/3)*(1 - (1 + k)*x + (-b + k)*x^2)),x]
Mathematica 13.1 output
\[ \frac {(-1+x) \left (3 k-\frac {3}{x}+\frac {(a+b) \sqrt [3]{\frac {x}{-1+x}} \sqrt [3]{\frac {-1+k x}{-1+x}} \left (2 \sqrt {3} \text {ArcTan}\left (\frac {\sqrt {3} \sqrt [3]{\frac {-1+k x}{-1+x}}}{2 \sqrt [3]{b} \left (\frac {x}{-1+x}\right )^{2/3}+\sqrt [3]{\frac {-1+k x}{-1+x}}}\right )+2 \log \left (-\sqrt [3]{b} \left (\frac {x}{-1+x}\right )^{2/3}+\sqrt [3]{\frac {-1+k x}{-1+x}}\right )-\log \left (b^{2/3} \left (\frac {x}{-1+x}\right )^{4/3}+\sqrt [3]{b} \left (\frac {x}{-1+x}\right )^{2/3} \sqrt [3]{\frac {-1+k x}{-1+x}}+\left (\frac {-1+k x}{-1+x}\right )^{2/3}\right )\right )}{\sqrt [3]{b}}\right )}{2 \sqrt [3]{(-1+x) x (-1+k x)}} \]
Mathematica 12.3 output
\[ \int \frac {(-2+(1+k) x) \left (1-(1+k) x+(a+k) x^2\right )}{x^2 \sqrt [3]{(1-x) x (1-k x)} \left (1-(1+k) x+(-b+k) x^2\right )} \, dx \]________________________________________________________________________________________