\[ \int \frac {a B+b B \cos (c+d x)}{(a+b \cos (c+d x))^2} \, dx \]
Optimal antiderivative \[ \frac {2 B \arctan \left (\frac {\sqrt {a -b}\, \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {a +b}}\right )}{d \sqrt {a -b}\, \sqrt {a +b}} \]
command
integrate((a*B+b*B*cos(d*x+c))/(a+b*cos(d*x+c))**2,x)
Sympy 1.10.1 under Python 3.10.4 output
\[ \begin {cases} \frac {\tilde {\infty } B x}{\cos {\left (c \right )}} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {B \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{b d} & \text {for}\: a = b \\\frac {B}{b d \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}} & \text {for}\: a = - b \\\frac {x \left (B a + B b \cos {\left (c \right )}\right )}{\left (a + b \cos {\left (c \right )}\right )^{2}} & \text {for}\: d = 0 \\\frac {B \log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {B \log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} \]
Sympy 1.8 under Python 3.8.8 output
\[ \text {Timed out} \]________________________________________________________________________________________