15.3 Problem number 295

\[ \int (g+h x)^2 \left (A+B \log \left (e (a+b x)^n (c+d x)^{-n}\right )\right ) \, dx \]

Optimal antiderivative \[ -\frac {B \left (-a d +b c \right ) h \left (-a d h -b c h +3 b d g \right ) n x}{3 b^{2} d^{2}}-\frac {B \left (-a d +b c \right ) h^{2} n \,x^{2}}{6 b d}-\frac {B \left (-a h +b g \right )^{3} n \ln \! \left (b x +a \right )}{3 b^{3} h}+\frac {B \left (-c h +d g \right )^{3} n \ln \! \left (d x +c \right )}{3 d^{3} h}+\frac {\left (h x +g \right )^{3} \left (A +B \ln \! \left (e \left (b x +a \right )^{n} \left (d x +c \right )^{-n}\right )\right )}{3 h} \]

command

integrate((h*x+g)^2*(A+B*log(e*(b*x+a)^n/((d*x+c)^n))),x, algorithm="giac")

Giac 1.9.0-11 via sagemath 9.6 output

\[ \text {Timed out} \]

Giac 1.7.0 via sagemath 9.3 output

\[ \frac {1}{3} \, {\left (A h^{2} + B h^{2}\right )} x^{3} + \frac {1}{3} \, {\left (B h^{2} n x^{3} + 3 \, B g h n x^{2} + 3 \, B g^{2} n x\right )} \log \left (b x + a\right ) - \frac {1}{3} \, {\left (B h^{2} n x^{3} + 3 \, B g h n x^{2} + 3 \, B g^{2} n x\right )} \log \left (d x + c\right ) - \frac {{\left (B b c h^{2} n - B a d h^{2} n - 6 \, A b d g h - 6 \, B b d g h\right )} x^{2}}{6 \, b d} + \frac {{\left (3 \, B a b^{2} g^{2} n - 3 \, B a^{2} b g h n + B a^{3} h^{2} n\right )} \log \left (b x + a\right )}{3 \, b^{3}} - \frac {{\left (3 \, B c d^{2} g^{2} n - 3 \, B c^{2} d g h n + B c^{3} h^{2} n\right )} \log \left (-d x - c\right )}{3 \, d^{3}} - \frac {{\left (3 \, B b^{2} c d g h n - 3 \, B a b d^{2} g h n - B b^{2} c^{2} h^{2} n + B a^{2} d^{2} h^{2} n - 3 \, A b^{2} d^{2} g^{2} - 3 \, B b^{2} d^{2} g^{2}\right )} x}{3 \, b^{2} d^{2}} \]