\[ \int \frac {\cos ^2(c+d x)}{a \cos (c+d x)+b \sin (c+d x)} \, dx \]
Optimal antiderivative \[ -\frac {b^{2} \arctanh \left (\frac {b \cos \left (d x +c \right )-a \sin \left (d x +c \right )}{\sqrt {a^{2}+b^{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}} d}+\frac {b \cos \left (d x +c \right )}{\left (a^{2}+b^{2}\right ) d}+\frac {a \sin \left (d x +c \right )}{\left (a^{2}+b^{2}\right ) d} \]
command
integrate(cos(d*x+c)**2/(a*cos(d*x+c)+b*sin(d*x+c)),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} \]_____________________________________________________