\[ \int (c x)^m \left (d+e x+f x^2+g x^3\right ) \left (a+b x^n\right )^p \, dx \]
Optimal antiderivative \[ \frac {d \left (c x \right )^{1+m} \left (a +b \,x^{n}\right )^{p} \hypergeom \left (\left [-p , \frac {1+m}{n}\right ], \left [\frac {1+m +n}{n}\right ], -\frac {b \,x^{n}}{a}\right ) \left (1+\frac {b \,x^{n}}{a}\right )^{-p}}{c \left (1+m \right )}+\frac {e \left (c x \right )^{2+m} \left (a +b \,x^{n}\right )^{p} \hypergeom \left (\left [-p , \frac {2+m}{n}\right ], \left [\frac {2+m +n}{n}\right ], -\frac {b \,x^{n}}{a}\right ) \left (1+\frac {b \,x^{n}}{a}\right )^{-p}}{c^{2} \left (2+m \right )}+\frac {f \left (c x \right )^{3+m} \left (a +b \,x^{n}\right )^{p} \hypergeom \left (\left [-p , \frac {3+m}{n}\right ], \left [\frac {3+m +n}{n}\right ], -\frac {b \,x^{n}}{a}\right ) \left (1+\frac {b \,x^{n}}{a}\right )^{-p}}{c^{3} \left (3+m \right )}+\frac {g \left (c x \right )^{4+m} \left (a +b \,x^{n}\right )^{p} \hypergeom \left (\left [-p , \frac {4+m}{n}\right ], \left [\frac {4+m +n}{n}\right ], -\frac {b \,x^{n}}{a}\right ) \left (1+\frac {b \,x^{n}}{a}\right )^{-p}}{c^{4} \left (4+m \right )} \]
command
integrate((c*x)**m*(g*x**3+f*x**2+e*x+d)*(a+b*x**n)**p,x)
Sympy 1.10.1 under Python 3.10.4 output
\[ \frac {a^{p} c^{m} d x x^{m} \Gamma \left (\frac {m}{n} + \frac {1}{n}\right ) {{}_{2}F_{1}\left (\begin {matrix} - p, \frac {m}{n} + \frac {1}{n} \\ \frac {m}{n} + 1 + \frac {1}{n} \end {matrix}\middle | {\frac {b x^{n} e^{i \pi }}{a}} \right )}}{n \Gamma \left (\frac {m}{n} + 1 + \frac {1}{n}\right )} + \frac {a^{p} c^{m} e x^{2} x^{m} \Gamma \left (\frac {m}{n} + \frac {2}{n}\right ) {{}_{2}F_{1}\left (\begin {matrix} - p, \frac {m}{n} + \frac {2}{n} \\ \frac {m}{n} + 1 + \frac {2}{n} \end {matrix}\middle | {\frac {b x^{n} e^{i \pi }}{a}} \right )}}{n \Gamma \left (\frac {m}{n} + 1 + \frac {2}{n}\right )} + \frac {a^{p} c^{m} f x^{3} x^{m} \Gamma \left (\frac {m}{n} + \frac {3}{n}\right ) {{}_{2}F_{1}\left (\begin {matrix} - p, \frac {m}{n} + \frac {3}{n} \\ \frac {m}{n} + 1 + \frac {3}{n} \end {matrix}\middle | {\frac {b x^{n} e^{i \pi }}{a}} \right )}}{n \Gamma \left (\frac {m}{n} + 1 + \frac {3}{n}\right )} + \frac {a^{p} c^{m} g x^{4} x^{m} \Gamma \left (\frac {m}{n} + \frac {4}{n}\right ) {{}_{2}F_{1}\left (\begin {matrix} - p, \frac {m}{n} + \frac {4}{n} \\ \frac {m}{n} + 1 + \frac {4}{n} \end {matrix}\middle | {\frac {b x^{n} e^{i \pi }}{a}} \right )}}{n \Gamma \left (\frac {m}{n} + 1 + \frac {4}{n}\right )} \]
Sympy 1.8 under Python 3.8.8 output
\[ \text {Timed out} \]________________________________________________________________________________________