\[ \int (a g+b g x)^4 \left (A+B \log \left (\frac {e (c+d x)^2}{(a+b x)^2}\right )\right ) \, dx \]
Optimal antiderivative \[ -\frac {2 B \left (-a d +b c \right )^{4} g^{4} x}{5 d^{4}}+\frac {B \left (-a d +b c \right )^{3} g^{4} \left (b x +a \right )^{2}}{5 b \,d^{3}}-\frac {2 B \left (-a d +b c \right )^{2} g^{4} \left (b x +a \right )^{3}}{15 b \,d^{2}}+\frac {B \left (-a d +b c \right ) g^{4} \left (b x +a \right )^{4}}{10 b d}+\frac {2 B \left (-a d +b c \right )^{5} g^{4} \ln \! \left (d x +c \right )}{5 b \,d^{5}}+\frac {g^{4} \left (b x +a \right )^{5} \left (A +B \ln \! \left (\frac {e \left (d x +c \right )^{2}}{\left (b x +a \right )^{2}}\right )\right )}{5 b} \]
command
integrate((b*g*x+a*g)^4*(A+B*log(e*(d*x+c)^2/(b*x+a)^2)),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 {2 \, B a^{5} g^{4} \log \left (b x + a\right )}{5 \, b} + \frac {1}{5} \, {\left (A b^{4} g^{4} + B b^{4} g^{4}\right )} x^{5} + \frac {{\left (B b^{4} c g^{4} + 10 \, A a b^{3} d g^{4} + 9 \, B a b^{3} d g^{4}\right )} x^{4}}{10 \, d} - \frac {2 \, {\left (B b^{4} c^{2} g^{4} - 5 \, B a b^{3} c d g^{4} - 15 \, A a^{2} b^{2} d^{2} g^{4} - 11 \, B a^{2} b^{2} d^{2} g^{4}\right )} x^{3}}{15 \, d^{2}} + \frac {1}{5} \, {\left (B b^{4} g^{4} x^{5} + 5 \, B a b^{3} g^{4} x^{4} + 10 \, B a^{2} b^{2} g^{4} x^{3} + 10 \, B a^{3} b g^{4} x^{2} + 5 \, B a^{4} g^{4} x\right )} \log \left (\frac {d^{2} x^{2} + 2 \, c d x + c^{2}}{b^{2} x^{2} + 2 \, a b x + a^{2}}\right ) + \frac {{\left (B b^{4} c^{3} g^{4} - 5 \, B a b^{3} c^{2} d g^{4} + 10 \, B a^{2} b^{2} c d^{2} g^{4} + 10 \, A a^{3} b d^{3} g^{4} + 4 \, B a^{3} b d^{3} g^{4}\right )} x^{2}}{5 \, d^{3}} - \frac {{\left (2 \, B b^{4} c^{4} g^{4} - 10 \, B a b^{3} c^{3} d g^{4} + 20 \, B a^{2} b^{2} c^{2} d^{2} g^{4} - 20 \, B a^{3} b c d^{3} g^{4} - 5 \, A a^{4} d^{4} g^{4} + 3 \, B a^{4} d^{4} g^{4}\right )} x}{5 \, d^{4}} + \frac {2 \, {\left (B b^{4} c^{5} g^{4} - 5 \, B a b^{3} c^{4} d g^{4} + 10 \, B a^{2} b^{2} c^{3} d^{2} g^{4} - 10 \, B a^{3} b c^{2} d^{3} g^{4} + 5 \, B a^{4} c d^{4} g^{4}\right )} \log \left (d x + c\right )}{5 \, d^{5}} \]