# Solving integral using trig substitution $\tan(x/2)=t$

I have problems with solving the following integral:

$$\int{{\sin x - \cos x}\over {\sin x + \cos x}} \, dx$$

Could anybody please help me to find the solution and show me the method how it can be solved? I already tried to solve similar ones but I get always stuck when trying the technique with partial fraction decomposition.

• What was your exact attempt? Where did you get stuck? And please use $\LaTeX$ next time. – Adrian Jan 18 '16 at 19:28
• Please include your thoughts and efforts (work in progress) in this and future posts. You are more likely to receive positive/constructive feedback that way. Formatting your post helps too. Formatting tips here. – Em. Jan 18 '16 at 19:29
• My answer doesn't tell you what the bottom line is, nor does it tell you how to evaluate the integral of the rational function that results from the substitution, but I think it gives a more detailed account of the substitution itself than the other answers do, and this particular substitution needs a fairly detailed account in order to be properly understood. ${}\qquad{}$ – Michael Hardy Jan 18 '16 at 20:11
• @addy2012 : It is at best very silly to call the math-notation typesetting software $\text{“}\LaTeX\text{''}$. It is MathJax. $\LaTeX$ doesn't just do mathematical notation, and that's not even most of what it does. People who master MathJax under the mistaken impression that they then know $\LaTeX$ are in for a shock if they try to use actual $\LaTeX$ and find they know next to nothing about it. ${}\qquad{}$ – Michael Hardy Jan 18 '16 at 20:12
• \relax, please :) – JnxF Jan 18 '16 at 20:32

Implementing the half-angle substitution (per your title), you have $$t=\tan\frac{x}{2}\implies\mathrm{d}t=\frac{1}{2}\sec^2\frac{x}{2}\,\mathrm{d}x$$ From the fact that $t=\tan\dfrac{x}{2}$, you can extract the following: $$\begin{cases}\sin x=2\sin\dfrac{x}{2}\cos\dfrac{x}{2}=\dfrac{2t}{1+t^2}\\[1ex] \cos x=\cos^2\dfrac{x}{2}-\sin^2\dfrac{x}{2}=\frac{1-t^2}{1+t^2}\\[1ex] \sec^2\dfrac{x}{2}=1+t^2\end{cases}$$ All of this tells you your initial integral is equivalent to $$\int\frac{\sin x-\cos x}{\sin x+\cos x}\,\mathrm{d}x=\int\frac{\frac{2t}{1+t^2}-\frac{1-t^2}{1+t^2}}{\frac{2t}{1+t^2}+\frac{1-t^2}{1+t^2}}\times\frac{2}{1+t^2}\,\mathrm{d}t=-2\int\frac{t^2+2t-1}{(t^2-2t-1)(1+t^2)}\,\mathrm{d}t$$ Decomposing into partial fractions yields $$-2\int\left(\frac{t-1}{t^2-2t-1}-\frac{t}{t^2+1}\right)\,\mathrm{d}t$$ Both integrals can easily be computed with substitutions that use the integrand's term's respective denominators.

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

Substitute $u=\sin(x)+\cos(x)$ and $\text{d}u=(\cos(x)-\sin(x))\space\text{d}x$:

$$-\int\frac{1}{u}\space\text{d}u=-\ln\left|u\right|+\text{C}=-\ln\left|\sin(x)+\cos(x)\right|+\text{C}$$

Hint:

substitute $t=\sin x +\cos x$ and $dt=(\cos x - \sin x)dx$

\begin{align} \tan \frac x 2 & = t \\[8pt] \frac x 2 & = \arctan t \\[8pt] x & = 2\arctan t \\[8pt] \sin x & = \sin(2\arctan t) = \sin(2 \, \bullet) = 2 \sin(\bullet)\cos(\bullet) \\ & = 2\sin(\arctan t)\cos(\arctan t), \\[8pt] \cos x & = \cos(2\arctan t) = \cos(2\,\bullet) = \cos^2(\bullet) - \sin^2(\bullet) \\ & = \cos^2(\arctan t) - \sin^2(\arctan t). \end{align}

Now let us consider what $\sin(\arctan t)$ and $\cos(\arctan t)$ are.

$\tan = \dfrac{\text{opposite}}{\text{adjacent}} = \dfrac t 1$ so $\text{hypotenuse} = \sqrt{t^2+1^2}$, and so we have $$\sin(\arctan t) = \frac{\text{opposite}}{\text{hypotenuse}} = \frac t {\sqrt{t^2+1}}.$$ Similarly $$\cos(\arctan t) = \frac{\text{adjacent}}{\text{hypotenuse}} = \frac 1 {\sqrt{t^2+1}}.$$ Consequently $$2\sin(\arctan t)\cos(\arctan t) = 2\cdot \frac 1 {\sqrt{t^2+1}} \cdot \frac t {\sqrt{t^2+1}} = \frac{2t}{1+t^2}.$$ Similarly $$\cos^2(\arctan t) - \sin^2(\arctan t) = \frac 1 {1+t^2} - \frac t {1+t^2} = \frac{1-t^2}{1+t^2}.$$ So now we have \left. \begin{align} \sin x & = \frac{2t}{1+t^2}, \\[10pt] \cos x & = \frac{1-t^2}{1+t^2}. \end{align} \right\} \tag 1

Finally, since $x = 2\arctan t$, we have $$dx = \frac{2\,dx}{1+t^2}. \tag 2$$

Your ultimate answer comes from $(1)$ and $(2)$, followed by actually evaluating the resulting integral of a rational function.

Notice, $$\int \frac{\sin x-\cos x}{\sin x+\cos x}\ dx$$$$=\int \frac{-(\cos x-\sin x)}{\sin x+\cos x}dx$$ $$=-\int \frac{d(\sin x+\cos x)}{\sin x+\cos x}$$ $$=\color{red}{-\ln|\sin x+\cos x|+C}$$

Notice, $$\int \frac{\sin x-\cos x}{\sin x+\cos x}\ dx$$ $$=\int \frac{\frac{\sin x}{\cos x}-1}{\frac{\sin x}{\cos x}+1}\ dx$$

$$=\int \frac{\tan x-1}{\tan x+1}\ dx$$

$$=\int \frac{\tan x-\tan\frac \pi4}{1+\tan x\tan\frac \pi4}\ dx$$ $$=\int\tan\left(x-\frac{\pi}{4}\right)\ dx$$ $$=\color{blue}{\ln\sec\left(x-\frac{\pi}{4}\right)+C}$$