\[ \int \frac {\cot ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx \]
Optimal antiderivative \[ -\frac {x}{\left (a -b \right )^{2}}+\frac {\left (5 a -3 b \right ) b^{\frac {3}{2}} \arctan \left (\frac {\sqrt {b}\, \tan \left (f x +e \right )}{\sqrt {a}}\right )}{2 a^{\frac {5}{2}} \left (a -b \right )^{2} f}-\frac {\left (2 a -3 b \right ) \cot \left (f x +e \right )}{2 a^{2} \left (a -b \right ) f}-\frac {b \cot \left (f x +e \right )}{2 a \left (a -b \right ) f \left (a +b \left (\tan ^{2}\left (f x +e \right )\right )\right )} \]
command
integrate(cot(f*x+e)**2/(a+b*tan(f*x+e)**2)**2,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} \]_____________________________________________________