<s>[INST] Evaluating $\int \frac{l\sin x+m\cos x}{(a\sin x+b\cos x)^2}dx$ How do I integrate this expression:
$$\int \frac{l\sin x+m\cos x}{(a\sin x+b\cos x)^2}dx$$.I got this in a book.I do not know how to evaluate integrals of this type.
 [/INST] One uses trigonometric substitution: $t = \tan\left(\frac{x}{2}\right)$. Then
$$
    \sin(x) = \frac{2t}{1+t^2}   \quad \cos(x) = \frac{1-t^2}{1+t^2} \quad \mathrm{d} x = \frac{2}{1+t^2} \mathrm{d} t 
$$
Hence:
$$\begin{eqnarray}
   \int \frac{ \ell \sin(x) + m \cos(x)}{(a \sin(x)+ b \cos(x))^2} \mathrm{d}x &=& \int \frac{ \ell \frac{2  t}{1-t^2} + m \frac{1-t^2}{1+t^2}}{\left(a \frac{2 t}{1+t^2}+ b \frac{1-t^2}{1+t^2}\right)^2} \frac{2}{1+t^2}\mathrm{d}t \\
 &=& \int \frac{2 \ell  t + m (1-t^2)}{\left(2 a t + b (1-t^2)\right)^2} 2 \mathrm{d}t
\end{eqnarray}$$
The resulting rational function can be integrated using partial fraction decomposition of the integrand, for example.
</s>