Indefinite integral of trignometric function What is the trick to integrate the following
$$\int \frac{1-\cos x}{(1+\cos x)\cos x}\ dx$$
 A: We have: Integrand = $\dfrac{1}{\cos x} - \dfrac{2}{1+\cos x} = \sec x - \sec^2 (x/2)$, and
$\displaystyle \int \sec x - \sec^2 (x/2)dx = \ln (\sec x + \tan x) - 2\tan(x/2) + C$
A: Using $$\cos2A=\frac{1-\tan^2A}{1+\tan^2A}$$
$$\int\frac{1-\cos x}{\cos x(1+\cos x)}dx$$
$$=\int\frac{2\sin^2\dfrac x2}{\cos^2\dfrac x2-\sin^2\dfrac x2}\frac12\sec^2\dfrac x2dx$$
$$=\int\frac{2\tan^2\dfrac x2}{1-\tan^2\dfrac x2}\frac12\sec^2\dfrac x2dx$$
$$=\int\frac{2u^2-2+2}{1-u^2}du=-2u+2\int\frac{du}{1-u^2}du$$
A: Hint :
\begin{align}
\int\frac{1-\cos x}{\cos(1+\cos x)}\ dx&=\int\frac{\color{red}{1+\cos x}-2\cos x}{\cos(\color{red}{1+\cos x})}\ dx\\
&=\int\frac1{\cos x}\ dx-\int\frac{2}{1+\cos x}\ dx\\
&=\int\frac{\cos x}{\cos^2 x}\ dx-\int\frac{2}{1+\cos x}\cdot\frac{1-\cos x}{1-\cos x}\ dx\\
&=\int\frac{d(\sin x)}{1-\sin^2 x}-\int\frac{2-2\cos x}{1-\cos^2 x}\ dx\\
&=\int\frac{d(\sin x)}{2(1-\sin x)}-\int\frac{d(\sin x)}{2(1+\sin x)}-\int\frac{2-2\cos x}{\sin^2 x}\ dx\\
&=\int\frac{d(\sin x)}{2(1-\sin x)}-\int\frac{d(\sin x)}{2(1+\sin x)}-\int\frac{2}{\sin^2 x}\ dx+2\int\frac{\cos x}{\sin^2 x}\ dx\\
&=\int\frac{d(\sin x)}{2(1-\sin x)}-\int\frac{d(\sin x)}{2(1+\sin x)}-2\int\csc^2x\ dx+2\int\frac{d(\sin x)}{\sin^2 x}\\
&=\int\frac{d(\sin x)}{2(1-\sin x)}-\int\frac{d(\sin x)}{2(1+\sin x)}+2\int\ d(\cot x)+2\int\frac{d(\sin x)}{\sin^2 x}.
\end{align}
