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.
 A: HINT:
$$\text{As }\frac{d(\tan mx)}{dx}=m\sec^2mx,$$
$$\int\sec^2mx= \frac{\tan mx}m+C$$
here $m=\frac12$
or using Weierstrass substitution $\tan \frac x2=t,$
$\frac x2=\arctan t\implies dx=2\frac{dt}{1+t^2}$  and $\cos x=\frac{1-t^2}{1+t^2}$
$$\int \frac{dx}{1+\cos x}=\int dt=t+K=\tan\frac x2+K$$
A: You were on the right track in the last line
$$ \frac{1}{2} \int \sec^2 \frac{x}{2} dx = \tan \frac{x}{2} + C $$
That's it. Put the limits in and you're done.
For the second one, substitute $t = \frac{\pi}{2} - x $ and you're back to the first integral
A: 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{ #}
$$
A: $$
\begin{array}{lcl}
\int_0^{\pi/2} \frac{1}{1+\cos x}dx &=& \int_0^{\pi/2} \frac{1}{(\cos^2(x/2)+\sin^2(x/2))+(\cos^2 (x/2)-\sin^2(x/2))}dx\\
&=& \int_0^{\pi/2} \frac{1}{2\cos^2(x/2)}dx\\
&=& \int_0^{\pi/4}\frac{1}{\cos^2u}du=\tan\frac{\pi}{4}=1
\end{array}
$$
A: $\int_a^bf(x)dx=\int_a^bf(a+b-x)dx$
Therefore, $$\int_0^{\pi/2}\dfrac{1}{1+\cos x}dx=\int_0^{\pi/2}\dfrac{1}{1+\sin x}dx$$
As you did $$\int_0^{\pi/2}\dfrac{1}{1+\cos x}dx=\frac{1}{2}\int_0^{\pi/2}\sec^2\frac{x}{2}dx$$
Substitute $x=2t$ and use $\int\sec^2 tdt=\tan t+C$
EDIT: Proof of $\int_a^bf(x)dx=\int_a^bf(a+b-x)dx$:
Let $I=\int_a^bf(x)dx$
Now, substitute $x=a+b-t\implies dx=-dt$
then $I=-\int_b^af(a+b-t)dt=\int_a^bf(a+b-t)dt=\int_a^bf(a+b-x)dx$$ 
