# Integration of trigonometric function $\int\frac{\sin(2x)}{\sin(x)-\cos(x)}dx$

$$\int\frac{\sin(2x)}{\sin(x)-\cos(x)}dx$$

My attempt: Firstly, $\sin(2x)=2\sin(x)\cos(x)$.

After that, eliminate the $\cos(x)$ seen in both the numerator and denominator to get

$$2\int\frac{\sin(x)}{\tan(x)-1}\ dx.$$

From here onwards, should I convert $\sin(x)$, $\tan(x)$ to half-angles and use $\tan(x/2)=t$?

But this would be a time consuming method. Any suggestions?

• As I see it, the half-angle tangent substitution, which you mentioned, is a very simple way here. Just try it - the numerator and denominator become very nice – Yuriy S Aug 6 '16 at 11:10

Hint: $$\int\frac{\sin(2x)}{\sin(x)-\cos(x)}dx = \int\frac{2\sin(x)\cos(x) }{\sin(x)-\cos(x)}dx = \int\frac{\sin(x)\cos(x)+\cos(x)\sin(x) }{\sin(x)-\cos(x)}dx\\ =\int\frac{\sin(x)\cos(x)-\sin^2(x)+\cos(x)\sin(x)-\cos^2(x)+1 }{\sin(x)-\cos(x)}dx \\=\int -\sin(x)dx+\int \cos(x)dx + \int \frac{1}{\sin(x) -\cos(x)}dx \\= \cos(x) + \sin(x) +\int \frac{1}{\sin(x) -\cos(x)}dx$$

For $$\int \frac{1}{\sin(x) -\cos(x)}dx$$:

Notice that $$\int \frac{1}{\sin(x) -\cos(x)}dx = \int \frac{1}{\sqrt{2} \sin(x-\frac{1}{4} \pi ) }dx$$

Let $$u = x-\frac{1}{4} \pi$$,

$$\int \frac{1}{\sqrt{2} \sin\left(x-\frac{1}{4} \pi \right) }dx = \int \frac{1}{\sqrt{2} } \csc(u)du$$

• There is a shortcut: write $\sin (2x)=1-(\sin (x) - cos (x))^2$. Is there a mistake in your sign? Shouln't it be $-\sin (x)?$ – Behnam Esmayli Aug 6 '16 at 16:44
• @Behnam Nope. there is no sign mistake. – Zack Ni Aug 7 '16 at 1:24

HINT:

$$\int\frac{\sin(2x)}{\sin(x)-\cos(x)}\space\text{d}x=$$

Use $\sin(2x)=2\sin(x)\cos(x)$:

$$2\int\frac{\sin(x)\cos(x)}{\sin(x)-\cos(x)}\space\text{d}x=$$

Sustitute $u=\tan\left(\frac{x}{2}\right)$ and $\text{d}u=\frac{x\sec^2\left(\frac{x}{2}\right)}{2}\space\text{d}x$:

$$-8\int\frac{u(u^2-1)}{(u^2+1)^2(u^2+2u-1)}\space\text{d}u$$

Now, use partial fractions.

Let $u=x-\frac\pi4$, then \begin{align} \int\frac{\sin(2x)}{\sin(x)-\cos(x)}\,\mathrm{d}x &=\int\frac{\sin\left(2u+\frac\pi2\right)}{\sqrt2\sin(u)}\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int\frac{\cos\left(2u\right)}{\sin(u)}\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int\frac{1-2\sin^2(u)}{\sin(u)}\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int\frac{\sin(u)}{1-\cos^2(u)}\,\mathrm{d}u-\sqrt2\int\sin(u)\,\mathrm{d}u\\ &=\sqrt2\cos(u)-\frac1{2\sqrt2}\int\left(\frac1{1-\cos(u)}+\frac1{1+\cos(u)}\right)\,\mathrm{d}\cos(u)\\ &=\sqrt2\cos(u)+\frac1{2\sqrt2}\log\left(\frac{1-\cos(u)}{1+\cos(u)}\right)+C\\ &=\sqrt2\cos(u)+\frac1{\sqrt2}\log(\tan(u/2))+C \end{align}

Let $$I = \int\frac{\sin 2x}{\sin x-\cos x}dx = \frac{1}{\sqrt{2}}\int\frac{\sin 2x}{\sin \left(x-\frac{\pi}{4}\right)}dx$$

Now Put $\displaystyle x- \frac{\pi}{4} = t\;,$ Then $dx = dt$

So $$I = \frac{1}{\sqrt{2}}\int\frac{\cos 2t}{\sin t}dt = \frac{1}{\sqrt{2}}\int \frac{1-2\sin^2 t}{\sin t}dt$$

So $$I = \frac{1}{\sqrt{2}}\int \csc t dt-\sqrt{2}\int \sin t dt$$

So $$I = \frac{1}{\sqrt{2}}\ln \left|\tan \frac{t}{2}\right|+\sqrt{2}\cos t+\mathcal{C}$$

So $$I = \frac{1}{\sqrt{2}}\ln \left|\tan \left(\frac{x-\frac{\pi}{4}}{2}\right)\right|+\sqrt{2}\cos \left(x-\frac{\pi}{4}\right)+\mathcal{C}$$

• Clever approach. How did you know that $\sin x-\cos x=\sqrt{2}\sin(x-\frac{\pi}{4})$. Did you use the sum identities and equate coefficients? – Ahmed S. Attaalla Aug 6 '16 at 12:30
• There will a $\sqrt(2)$ before $\cos(x-\pi/4)$ in last step. – user220382 Aug 6 '16 at 13:05

I like trigonometric substitutions so I will try to implement that !

Use $\sin(x)-\cos(x)=z$.Find numerator in terms of $z^2$.

Then $(\cos(x)+\sin(x))dx=dz$

$\sin(x)-\cos(x)=z$ so,$z^2=1-\sin(2x)$

Also $(\sin(x)+\cos(x))^2+ (\sin(x)-\cos(x))^2=2$

So the integral boils down to

$$\frac{1-z^2}{z(\sqrt{2-z^2})}dz$$

Substitute $z=\sqrt{2}\sin(y)$ The integral becomes $$\int \frac{\cos(2y)}{\sqrt{2}\sin(y)}dy$$ $$\int \frac{\csc(y)-2\sin(y)}{\sqrt{2}}dy$$ which equals $$\frac{1}{\sqrt{2}}\ln|\tan(y/2)|+\sqrt{2}\cos(y)+C$$

On resubstituting original variables we get $$\frac{1}{\sqrt{2}}\ln \left|\tan \left(\frac{x-\frac{\pi}{4}}{2}\right)\right|+\sqrt{2}\cos \left(x-\frac{\pi}{4}\right)+\mathcal{C}$$

Hurray ! :-)

Assuming $$u=x-\frac\pi4$$ \begin{align} \int\frac{\sin(2x)}{\sin(x)-\cos(x)}\,\mathrm{d}x &=\int\frac{\sin\left(2u+\frac\pi2\right)}{\sqrt2\sin(u)}\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int\frac{\cos\left(2u\right)}{\sin(u)}\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int\frac{1-2\sin^2(u)}{\sin(u)}\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int\left(\csc u -2\sin u\right)\,\mathrm{d}u\\ &=\frac1{\sqrt2}\int \csc u \text{du} -2\sin u \text{du} \\ &=\frac1{\sqrt2}\left(\log \left|\tan \frac{u}{2}\right| +2\cos u\right) \\ \end{align}

• There is a mistake in your final answer.Otherwise your method is nice! – user220382 Aug 6 '16 at 16:17
• @SanchayanDutta Fixed it – Aakash Kumar Aug 6 '16 at 16:23