\[ \int \frac {(-2+(1+k) x) \left (a-a (1+k) x+(1+a k) x^2\right )}{(-1+x) \sqrt [3]{(1-x) x (1-k x)} (-1+k x) \left (b-b (1+k) x+(-1+b k) x^2\right )} \, dx \]
Optimal antiderivative \[ \frac {3 \left (k \,x^{3}-k \,x^{2}-x^{2}+x \right )^{\frac {2}{3}}}{\left (-1+x \right ) \left (k x -1\right )}+\frac {\left (-\sqrt {3}\, a -b \sqrt {3}\right ) \arctan \left (\frac {\sqrt {3}\, x}{x +2 b^{\frac {1}{3}} \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {1}{3}}}\right )}{b^{\frac {2}{3}}}+\frac {\left (a +b \right ) \ln \left (x -b^{\frac {1}{3}} \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {1}{3}}\right )}{b^{\frac {2}{3}}}+\frac {\left (-a -b \right ) \ln \left (x^{2}+b^{\frac {1}{3}} x \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {1}{3}}+b^{\frac {2}{3}} \left (x +\left (-1-k \right ) x^{2}+k \,x^{3}\right )^{\frac {2}{3}}\right )}{2 b^{\frac {2}{3}}} \]
command
Integrate[((-2 + (1 + k)*x)*(a - a*(1 + k)*x + (1 + a*k)*x^2))/((-1 + x)*((1 - x)*x*(1 - k*x))^(1/3)*(-1 + k*x)*(b - b*(1 + k)*x + (-1 + b*k)*x^2)),x]
Mathematica 13.1 output
\[ \frac {(-1+x) \left (\frac {6 x}{-1+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]{b} \sqrt [3]{\frac {-1+k x}{-1+x}}}{2 \left (\frac {x}{-1+x}\right )^{2/3}+\sqrt [3]{b} \sqrt [3]{\frac {-1+k x}{-1+x}}}\right )+2 \log \left (\left (\frac {x}{-1+x}\right )^{2/3}-\sqrt [3]{b} \sqrt [3]{\frac {-1+k x}{-1+x}}\right )-\log \left (\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}}+b^{2/3} \left (\frac {-1+k x}{-1+x}\right )^{2/3}\right )\right )}{b^{2/3}}\right )}{2 \sqrt [3]{(-1+x) x (-1+k x)}} \]
Mathematica 12.3 output
\[ \int \frac {(-2+(1+k) x) \left (a-a (1+k) x+(1+a k) x^2\right )}{(-1+x) \sqrt [3]{(1-x) x (1-k x)} (-1+k x) \left (b-b (1+k) x+(-1+b k) x^2\right )} \, dx \]________________________________________________________________________________________