<s>[INST] How to integrate these integrals $$\int^{\frac {\pi}2}_0 \frac {dx}{1+ \cos x}$$
$$\int^{\frac {\pi}2}_0 \frac {dx}{1+ \sin x}$$
It seems that substitutions make things worse:
$$\int \frac {dx}{1+ \cos x} ; t = 1 + \cos x; dt = -\sin x dx ; \sin x = \sqrt{1 - \cos^2 x} = \sqrt{1 - (t-1)^2} $$
$$ \Rightarrow
\int \frac {-\sqrt{1 - (t-1)^2}}{t} = \int \frac {-\sqrt{t^2 + 2t}}{t} = \int \frac {-\sqrt t \cdot \sqrt t \cdot \sqrt{t +
2}}{\sqrt t \cdot t} $$
$$= \int \frac {- \sqrt{t + 2}}{\sqrt t } = \int  - \sqrt{1 + \frac 2t} = ? $$
What next? I don’t know. Also, I’ve tried another “substitution”, namely $1 + \cos x = 2 \cos^2 \frac x2) $
$$ \int \frac {dx}{1+ \cos x} = \int \frac {dx}{2 \cos^2 \frac x2} = \int \frac 12 \cdot \sec^2 \frac x2 = ? $$
And failed again. Help me, please.
 [/INST] Use this simple trigonometry manipulation:
$$
\frac{1}{1+\cos x}=\frac{1}{1+\cos x}\cdot\frac{1-\cos x}{1-\cos x}=\frac{1-\cos x}{\sin^2 x}.
$$
Therefore
$$
\begin{align}
\int\frac{1}{1+\cos x}\;dx&=\int\frac{1-\cos x}{\sin^2 x}\;dx\\
&=\int\frac{1}{\sin^2 x}\;dx-\int\frac{\cos x}{\sin^2 x}\;dx\\
&=-\int\;d(\cot x)-\int\frac{1}{\sin^2 x}\;d(\sin x)\\
&=-\cot x+\frac{1}{\sin x}+C\\
&=\frac{1-\cos x}{\sin x}+C\\
&=\frac{\sin^2\frac{1}{2}x+\cos^2\frac{1}{2}x-\cos^2\frac{1}{2}x+\sin^2\frac{1}{2}x}{2\sin\frac{1}{2}x\cos\frac{1}{2}x}+C\\
&=\tan\frac{1}{2}x+C.
\end{align}
$$
Similarly with
$$
\frac{1}{1+\sin x}=\frac{1}{1+\sin x}\cdot\frac{1-\sin x}{1-\sin x}=\frac{1-\sin x}{\cos^2 x}.
$$

$$
\text{# }\mathbb{Q.E.D.}\text{ #}
$$
</s>