<s>[INST] integration by substitution, using $\;t = \tan \left(\frac 12 x\right)$ $\displaystyle\int_0^\frac{\pi}{2}\frac{1}{2-\cos x} \, dx$ using the substitution $t=\tan\frac{1}{2}x$

  
*
  
*$x=2\tan^{-1}t$
  
*$\dfrac{dx}{dt}=\dfrac{2}{1+t^2}$
  
*$dx=\dfrac{2}{1+t^2}\,dt$
  
*$\displaystyle\int_0^1 \left(\frac{1}{2-\cos x}\right)\left(\frac{2}{1+t^2}\right)\,dt$ 

Is this the right idea? If so what do I do next?
$\displaystyle\int_0^1\left(\frac{1}{2-\frac{1-t^2}{1+t^2}}\right) \,\left(\frac{2}{1+t^2}\right)\, dt$
$\displaystyle\int_0^1\frac{2}{1+3t^2}\,dt$
$=2\left[\frac{\ln(1+3t^2)}{6t}\right]_0^1$
 [/INST] Hint: 
When $\tan \dfrac{x}{2}=t$ you have $ \cos x= \dfrac{1-t^2}{1+t^2}$
</s>