\[ \int (a g+b g x) (c i+d i x) \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 )^{2} g i n x}{6 b d}+\frac {g i \left (b x +a \right )^{2} \left (d x +c \right ) \left (A +B \ln \! \left (e \left (\frac {b x +a}{d x +c}\right )^{n}\right )\right )}{3 b}+\frac {\left (-a d +b c \right ) g i \left (b x +a \right )^{2} \left (A -B n +B \ln \! \left (e \left (\frac {b x +a}{d x +c}\right )^{n}\right )\right )}{6 b^{2}}+\frac {B \left (-a d +b c \right )^{3} g i n \ln \! \left (d x +c \right )}{6 b^{2} d^{2}} \]
command
integrate((b*g*x+a*g)*(d*i*x+c*i)*(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
\[ \begin {cases} a c g i x \left (A + B \log {\left (e \left (\frac {a}{c}\right )^{n} \right )}\right ) & \text {for}\: b = 0 \wedge d = 0 \\a g \left (A c i x + \frac {A d i x^{2}}{2} - \frac {B c^{2} i n \log {\left (c + d x \right )}}{2 d} + B c i n x \log {\left (a \right )} - B c i n x \log {\left (c + d x \right )} + \frac {B c i n x}{2} + B c i x \log {\left (e \right )} + \frac {B d i n x^{2} \log {\left (a \right )}}{2} - \frac {B d i n x^{2} \log {\left (c + d x \right )}}{2} + \frac {B d i n x^{2}}{4} + \frac {B d i x^{2} \log {\left (e \right )}}{2}\right ) & \text {for}\: b = 0 \\c i \left (A a g x + \frac {A b g x^{2}}{2} + \frac {B a^{2} g n \log {\left (\frac {a}{c} + \frac {b x}{c} \right )}}{2 b} + B a g n x \log {\left (\frac {a}{c} + \frac {b x}{c} \right )} - \frac {B a g n x}{2} + B a g x \log {\left (e \right )} + \frac {B b g n x^{2} \log {\left (\frac {a}{c} + \frac {b x}{c} \right )}}{2} - \frac {B b g n x^{2}}{4} + \frac {B b g x^{2} \log {\left (e \right )}}{2}\right ) & \text {for}\: d = 0 \\A a c g i x + \frac {A a d g i x^{2}}{2} + \frac {A b c g i x^{2}}{2} + \frac {A b d g i x^{3}}{3} - \frac {B a^{3} d g i n \log {\left (\frac {a}{c + d x} + \frac {b x}{c + d x} \right )}}{6 b^{2}} - \frac {B a^{3} d g i n \log {\left (\frac {c}{d} + x \right )}}{6 b^{2}} + \frac {B a^{2} c g i n \log {\left (\frac {a}{c + d x} + \frac {b x}{c + d x} \right )}}{2 b} + \frac {B a^{2} c g i n \log {\left (\frac {c}{d} + x \right )}}{2 b} + \frac {B a^{2} d g i n x}{6 b} - \frac {B a c^{2} g i n \log {\left (\frac {c}{d} + x \right )}}{2 d} + B a c g i n x \log {\left (\frac {a}{c + d x} + \frac {b x}{c + d x} \right )} + B a c g i x \log {\left (e \right )} + \frac {B a d g i n x^{2} \log {\left (\frac {a}{c + d x} + \frac {b x}{c + d x} \right )}}{2} + \frac {B a d g i n x^{2}}{6} + \frac {B a d g i x^{2} \log {\left (e \right )}}{2} + \frac {B b c^{3} g i n \log {\left (\frac {c}{d} + x \right )}}{6 d^{2}} - \frac {B b c^{2} g i n x}{6 d} + \frac {B b c g i n x^{2} \log {\left (\frac {a}{c + d x} + \frac {b x}{c + d x} \right )}}{2} - \frac {B b c g i n x^{2}}{6} + \frac {B b c g i x^{2} \log {\left (e \right )}}{2} + \frac {B b d g i n x^{3} \log {\left (\frac {a}{c + d x} + \frac {b x}{c + d x} \right )}}{3} + \frac {B b d g i x^{3} \log {\left (e \right )}}{3} & \text {otherwise} \end {cases} \]