Tangent half angle substitution is used to integrate the rational functions of $sine$ and $cosine$. We have to use tangent half angle substitution because trigonometric or $u$ substitution does not work particularly well for such functions. 

The trigonometric substitution will not work in the case of a rational function of sine and cosine because if we substitute an inverse trigonometric function then a complicated differential appears and if we try to replace with a regular trigonometric function then we will get nested functions and things get worse. 

We will also find it difficult to use a $u - substitution$ for the rational function of sine and cosine. A regular function like $x$ or $2x$ used for $u$ substitution does not work because if we do that we will be left with a $dx$ term unaccounted for. 

Hence, we use the substitution  $t$ = tan⁡ $(\frac{x}{2})$, which is a tangent half angle substitution. 



When we say  t=tan⁡($\frac{x}{2}$), then we know that the ratio of opposite and base is   $\frac{t}{1}$, i.e. the opposite side is of length $t$ units and base is of length $1$ unit. From this, we can say that the length of the hypotenuse will be $\sqrt{(t^2 + 1)}$. 

image

Once we draw the triangle, we can write the following:

cos ($\frac{x}{2}$) = $\frac{1}{\sqrt{(t^2+1)}}$

sin($\frac{x}{2}$)  =  $\frac{t}{\sqrt{(t^2+1)}}$

We can also find the value of   $cos⁡(x)$  and  $sin⁡(x)$  from the given information.

$cos(x)$ = $cos(2 \times \frac{x}{2})$ = $2 cos^2(\frac{x}{2})$ - 1  = 2 $\times$ $({\frac{1}{t^2 + 1}})^2$ - 1 = $\frac{1-t^2}{1+t^2}$

$sin(x)$ = $2 \times sin(\frac{x}{2}) \times cos(\frac{x}{2})$ = $2 \times \frac{t}{\sqrt{t^2+1}} \times \frac{1}{\sqrt{t^2+1}}$ = $\frac{2t}{t^2 + 1}$

We can use these formulas for tangent half-angle substitution. 
Let us take an example to see how we can integrate using tangent half angle substitution. 

$\int \frac{1}{3 - 5sinx}$

If we have to integrate the given function then we start by substituting  t = tan⁡ $(\frac{x}{2})$.

We first need to find the value of  $dx$.

We have, 

$t$ = tan⁡ $(\frac{x}{2})$
   
$\Rightarrow$ $\frac{x}{2}$ = $tan^{-1}(t)$
   
$\Rightarrow$ $x$ = 2 $tan^{-1}(t)$
   
$\Rightarrow$ $dx$ = $2$ $\times$ $\frac{1}{1+t^2}$
   
We also need to use the formula for $sin⁡(x)$ that was derived earlier. 

$sin(x)$ = $\frac{2t}{1+t^2}$

Hence, the given integral becomes:

$\int \frac{1}{3 - 5sinx}$ $dx$ = $\int \frac{1}{3 - 5(\frac{2t}{1+t^2})}$ $\times$ $\frac{2}{1+t^2}$ $dt$ = $\int \frac{\frac{2}{1+t^2}}{ 3 - \frac{10t}{t^2 +1}}$

= $\int \frac{1}{3 - 5sinx}$ $dx$ = $\int \frac{2}{3t^2 - 10t +3}$ $dt$ = $\int \frac{2}{(3t-1)(t-3)}$ $dt$

Now, we need to do partial fraction decomposition. 

$\frac{2}{(3t-1)(t-3)}$ = $\frac{A}{3t - 1}$ + $\frac{B}{t - 3}$

Multiplying both sides by $(3t-1)(t-3) $

$2$ = $A(t-3) + B(3t-1)$

Substituting $t$ = $3$ in the above equation we get

$2$ = $B((3 \times 3) - 1)$ = $B \times 8$

$\Rightarrow$ $B$ = $\frac{2}{8}$ = $\frac{1}{4}$

Substituting $t$ = $\frac{1}{3}$ we get

$2$ = $A$ $(\frac{1}{3}$ $- 3)$ = $A\ \times$ $\frac{(-8)}{3}$

$\Rightarrow\ A$ = - $\frac{6}{8}$ = -$\frac{3}{4}$

Substituting the values of $A$ and $B$

$\frac{2}{(3t-1)(t-3)}$ = $\frac{(-\frac{3}{4})}{(3t-1)}$ +  $\frac{(\frac{1}{4})}{(t-3)}$

Hence, the integral becomes

$\int \frac{1}{3 - 5sinx}$ $dx$ = $\int \frac{(-\frac{3}{4})}{(3t-1)}$$\int \frac{(\frac{1}{4})}{(t-3)}$

$\int \frac{1}{3 - 5sinx}$ $dx$ = - $\frac{3}{4}$ $\times$ $\frac{1}{3}$ $\times$ ln $\left | 3t - 1 \right |$ + $\frac{1}{4}$ ln $\left | t - 3 \right |$ $+ c$

$\int \frac{1}{3 - 5sinx}$ $dx$ = -$\frac{1}{4}$ $\left | 3t - 1 \right |$ + $\frac{1}{4}$ ln $\left | t - 3 \right |$ $+ c$

Substituting back the value of $t$

$\int \frac{1}{3 - 5sinx}$ $dx$ = -$\frac{1}{4}$ $\left | 3 tan(\frac{x}{2}) - 1 \right |$ + $\frac{1}{4}$ ln $\left | tan(\frac{x}{2}) - 3 \right |$ $+ c$

This will be the final answer for the given question.
Question: 

Integrate  $\int \frac{1}{2+cos x}$ $dx$

Solution:

If we have to integrate the given function then we start by substituting  $t$ = tan ⁡$(\frac{x}{2})$.

We first need to find the value of  $dx$.

We have, 

$t$ = tan ⁡$(\frac{x}{2})$
   
$\Rightarrow$ $\frac{x}{2}$ = $tan^{-1}(t)$
   
$\Rightarrow\ x$ = 2 $tan^{-1}(t)$
   
$\Rightarrow\ dx$ = $2\ \times$ $\frac{1}{1+t^2}$
   
We also need to use the formula for $cos⁡(x)$ that was derived earlier. 

$cos⁡(x)$ = $\frac{(1-t^2}{(1+t^2)}$

So, the integral becomes 

$\int \frac{1}{2+cos x}$ $dx$ = $\int \frac{1}{2+\frac{(1-t^2}{(1+t^2)}}$ $\times$ $\frac{2}{1 +t^2}$ $dt$ = $\int \frac{2}{2 + 2t^2 + 1- t^2}$ $dt$

$\int \frac{1}{2+cos x}$ $dx$ = $\int \frac{2}{3+t^2}$ $dt$ = $\frac{2}{3}$ $\int \frac{1}{1+ \frac{t^2}{3}}$ $dt$ = $\frac{2}{3}$ $\int \frac{1}{1+(\frac{t}{\sqrt 3})^2}$ $dt$

Now we substitute  $u$ = $\frac{t}{\sqrt 3}$ $\Rightarrow\ du$ = $\frac{1}{\sqrt 3}$  $dt\ \Rightarrow\ dt$ = $\sqrt 3$  $du$

The integral becomes

$\Rightarrow$ $\int \frac{1}{2+cos x}$ $dx$ = $\frac{2}{3}$ $\int \frac{1}{1+u^2}$ $\sqrt 3$ $du$  = $\frac{2 \sqrt3}{3}$ $\int \frac{1}{1+u^2}$ $du$ = $\frac{2}{\sqrt 3}$ $tan^{-1}u  + c$

Substituting back the value of $u$

$\int \frac{1}{2+cos x}$ $dx$ = $\frac{2}{\sqrt 3}$ $tan^{-1}(\frac{t}{\sqrt 3})$ $+ c$

Again, substituting back the value of $t$

$\int \frac{1}{2+cos x}$ $dx$ = $\frac{2}{\sqrt 3}$ $tan^{-1}(\frac{tan(\frac{x}{2})}{\sqrt 3})$ $+ c$

This will be the final answer for the given question.