\[ \int (f+g x)^2 \left (A+B \log \left (e \left (\frac {a+b x}{c+d x}\right )^n\right )\right ) \, dx \]
Optimal antiderivative \[ -\frac {B \left (-a d +b c \right ) g \left (-a d g -b c g +3 b d f \right ) n x}{3 b^{2} d^{2}}-\frac {B \left (-a d +b c \right ) g^{2} n \,x^{2}}{6 b d}-\frac {B \left (-a g +b f \right )^{3} n \ln \! \left (b x +a \right )}{3 b^{3} g}+\frac {\left (g x +f \right )^{3} \left (A +B \ln \! \left (e \left (\frac {b x +a}{d x +c}\right )^{n}\right )\right )}{3 g}+\frac {B \left (-c g +d f \right )^{3} n \ln \! \left (d x +c \right )}{3 d^{3} g} \]
command
integrate((g*x+f)**2*(A+B*ln(e*((b*x+a)/(d*x+c))**n)),x)
Sympy 1.10.1 under Python 3.10.4 output
\[ \text {Timed out} \]
Sympy 1.8 under Python 3.8.8 output
\[ \text {output too large to display} \]