# 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.

-
Just a note: one evaluates integrals and solves equations. – Joe Jul 19 '12 at 4:02
I edited the question. – Lingqiao Jul 19 '12 at 4:05

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.

-
How will the partial fraction decomposition done?It is a very large expression,is it not? – Lingqiao Jul 19 '12 at 4:23
$$\frac{2 \left(m \left(1-t^2\right)+2 t \ell \right)}{\left(2 a t+b \left(1-t^2\right)\right)^2}=\frac{4 t (b \ell -a m)}{b \left(-2 a t+b t^2-b\right)^2}-\frac{2 m}{b \left(-2 a t+b t^2-b\right)}$$ – Sasha Jul 19 '12 at 4:43
If one is using the Weierstrass substitution for evaluating definite integrals, one should of course be careful, since the substitution function might be discontinuous within the integration interval... – J. M. Jul 19 '12 at 5:32

There is a universal solution, based on the Weierstrass substitution $t=\tan(x/2)$. We end up integrating a pretty awful but rational function of $t$. This is handled usually with partial fractions.

We get $dx=\frac{2\,dt}{1+t^2}$, $\sin x=\frac{2t}{1+t^2}$ and $\cos x=\frac{1-t^2}{1+t^2}$.

The same substitution works for any rational function of $\sin x$ and $\cos x$.

-

You can try Weierstrass substitution: $t = \tan \frac x 2$, which will convert the integrand into a rational function of $t$.

-
Must have been still typing when Andr\'e got his answer up. – Morgan Sherman Jul 19 '12 at 4:18
Err..., and Sasha – Morgan Sherman Jul 19 '12 at 4:19

Use the famous equation $$a\cos x + b\sin x = \pm \sqrt{a^2 + b^2}\cos\left(x - \arctan(b/a)\right)$$ and let $\alpha = \arctan(b/a)$ to get \begin{aligned} \mathcal{J}&=\int\dfrac{\ell \sin x + m\cos x}{(a^2 + b^2)\cos^2\left(x - \alpha\right)}\,\mathrm{d}x\\ &=\frac{1}{a^2 + b^2}\int\dfrac{\ell\sin(x - \alpha+\alpha) + m\cos(x-\alpha + \alpha)}{\cos^2\left(x-\alpha\right)}\,\mathrm{d}x\\ &=\frac{1}{a^2+b^2}\int\dfrac{\ell\left[\sin(x-\alpha)\cos\alpha + \sin\alpha\cos(x-\alpha)\right]+m\left[\cos(x-\alpha)\cos\alpha-\sin(x-\alpha)\sin\alpha\right]}{\cos^2\left(x-\alpha\right)}\,\mathrm{d}x\\ &=\frac{1}{a^2+b^2}\int\frac{\sin(x-\alpha)\left(\ell\cos\alpha-m\sin\alpha\right) + \cos(x-\alpha)\left(\ell\sin\alpha+m\cos\alpha\right)}{\cos^2\left(x-\alpha\right)}\,\mathrm{d}x\\ &=\dfrac{\ell\cos\alpha-m\sin\alpha}{a^2+b^2}\int\sec(x-\alpha)\tan(x-\alpha)\,\mathrm{d}x+\dfrac{\ell\sin\alpha+m\cos\alpha}{a^2+b^2}\int\sec(x-\alpha)\,\mathrm{d}x\\ &=\dfrac{\ell\cos\alpha-m\sin\alpha}{a^2+b^2}\sec(x-\alpha) + \dfrac{\ell\sin\alpha+m\cos\alpha}{a^2+b^2}\ln\left|\sec(x-\alpha)+\tan(x-\alpha)\right|+C. \end{aligned}

And we are done.

-