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