Compute $\int_0^{\pi/2}\frac{\cos{x}}{2-\sin{2x}}dx$ How can I evaluate the following integral?

$$I=\int_0^{\pi/2}\frac{\cos{x}}{2-\sin{2x}}dx$$  


I tried it with Wolfram Alpha, it gave me a numerical solution: $0.785398$.
Although I immediately know that it is equal to $\pi /4$, I fail to obtain the answer with pen and paper.
I tried to use substitution $u=\tan{x}$, but I failed because the upper limit of the integral is $\pi/2$ and $\tan{\pi/2}$ is undefined.
So how are we going to evaluate this integral? Thanks.
 A: Here is a step by step approach. :)
$$\begin{align}
I &= \int_0^{\pi/2}\frac{\cos{x}}{2-\sin{2x}}dx \\
&= \int_0^{\pi/2}\frac{\cos{x}}{2-2 \sin x \cos x}dx \\
&= \int_0^{\pi/2}\frac{\cos{x}}{1+\cos^2 x -2 \sin x \cos x + \sin^2 x}dx \\
&= \int_0^{\pi/2}\frac{\cos{x}}{1+(\cos x - \sin x)^2}dx \\
&= \frac{1}{2} \left( \int_0^{\pi/2}\frac{\cos{x}}{1+(\cos x - \sin x)^2}dx + \int_0^{\pi/2}\frac{\sin{x}}{1+(\cos x - \sin x)^2}dx \right) \\
&= \frac{1}{2} \int_0^{\pi/2}\frac{\cos{x} + \sin{x}}{1+(\cos x - \sin x)^2}dx \\
&= -\frac{1}{2} \int_0^{\pi/2}\frac{d(\cos{x} - \sin{x})}{1+(\cos x - \sin x)^2}\\
&= -\frac{1}{2}\arctan(\cos{x}-\sin{x})|_{0}^{\frac{\pi}{2}} \\
&= \frac{\pi}{4}
\end{align}$$
A: I write simplify.
$$
=\int\frac{d\sin(x-\pi /4)}{ 2 \sin^2(x-\pi/4) +1 }
$$
Before it, use $ u=\pi/2 $ to get numerator $\sin x $ and $\cos x$ is same value.
A: Hint:
1) $\sin 2x=2\sin x \cos x$
2) $\sin x =\frac {2t}{1+t^2}$
$\cos x =\frac {1-t^2}{1+t^2}$
$dx=\frac{2dt}{1+t^2}$
A: Hint:
Knowing that $\sin2x=2\sin x\cos x$ and $\sin^2x+\cos^2x=1$. The integral can be expressed as
\begin{equation}
I=\int_0^{\pi/2}\frac{\cos x}{1+(\sin x-\cos x)^2}\ dx
\end{equation}
then use substitution $x\mapsto\frac{\pi}{2}-x$, we have
\begin{equation}
I=\int_0^{\pi/2}\frac{\sin x}{1+(\sin x-\cos x)^2}\ dx
\end{equation}
Add the two $I$'s and let $u=\sin x-\cos x$.
A: There are 5 wonderful solutions already. I want to share with you one more alternative which is long but hopefully interesting.
Using $\sin 2x=2\sin x\cos x$ and multiplying both denominator and numerator by $1-\sin x \cos x$ rewrites$$
I=\frac{1}{2} \int_{0}^{\frac{\pi}{2}} \frac{\cos x+\sin x \cos ^2x}{1-\sin ^{2} x \cos ^{2} x} d x
$$
Splitting the numerator into 2 parts and letting respectively $\sin x \mapsto x$ and $\cos x\mapsto x $ yields
$$
\begin{array}{l} \displaystyle    I=\frac{1}{2} \int_{0}^{1} \frac{1+x^{2}}{x^{4}-x^{2}+1} d x \\
\displaystyle \quad =\frac{1}{2} \int_{0}^{1} \frac{\frac{1}{x^{2}}+1}{x^{2}+\frac{1}{x^{2}}-1} d x \\
\displaystyle \quad =\frac{1}{2} \int_{0}^{1} \frac{d\left(x-\frac{1}{x}\right)}{\left(x-\frac{1}{x}\right)^{2}+1} \\
\displaystyle \quad =\frac{1}{2}\left[\tan ^{-1}\left(x-\frac{1}{x}\right)\right]_{0}^{1} \\
\displaystyle \quad =\frac{1}{2}\left[0-\left(-\frac{\pi}{2}\right)\right] \\
\displaystyle \quad =\frac{\pi}{4}
\end{array}
$$
A: Use $$I=\int_a^bf(x)dx=\int_a^bf(a+b-x)dx$$
and $$2I=\int_a^bf(x)dx+\int_a^bf(a+b-x)dx=\int_a^b\left(f(x)+f(a+b-x)\right)dx$$
$$2I=\int_0^{\pi/2}\dfrac{\cos x+\sin x}{2-\sin2x}dx$$
As $\int(\cos x+\sin x)\ dx=\sin x-\cos x,$
let $\sin x-\cos x=u\implies u^2=1-\sin2x$
Can you take it from here?
