Prove that $ \int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x =\int_0^{\pi} \frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x $ In a related question the following integral was evaluated
$$ 
      \int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x
     =\int_0^{\pi} \frac{\mathrm{d}x/2}{1 + \cos x \sin x} 
     =\int_0^{2\pi}  \frac{\mathrm{d}x/2}{2 + \sin x} \,\mathrm{d}x
     =\int_{-\infty}^\infty \frac{\mathrm{d}x/2}{1+x+x^2}
$$
I noticed something interesting, namely that
$$ 
\begin{align*}
        \int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x
    & = \int_0^{\pi} \frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x \\
    & = \int_0^{\pi} \frac{(\cos x)^2}{1 - \cos x \sin x} \,\mathrm{d}x
      = \int_0^{\pi} \frac{(\sin x)^2}{1 - \cos x \sin x} \,\mathrm{d}x
\end{align*}
$$
The same trivially holds if the upper limits are changed to $\pi/2$ as well ($x \mapsto \pi/2 -u$).
But I had problems proving the first equality. Does anyone have some quick hints?
 A: Subtract the two integrals in question and get
$$\int_0^{\pi} dx \frac{\cos{2 x}}{1+\frac12 \sin{2 x}} = \frac12 \int_0^{2 \pi} du \frac{\cos{u}}{1+\frac12 \sin{u}}$$
This may be shown to be equal to  the complex integral
$$-\frac{i}{4} \oint_{|z|=1} \frac{dz}{z} \frac{z+z^{-1}}{1+\frac{1}{4 i} (z-z^{-1})}  = \oint_{|z|=1}\frac{dz}{z} \frac{z^2+1}{z^2+i 4 z-1}$$
The poles of the integrand within the unit circle are at $z=0$ and $z=-(2-\sqrt{3}) i$; their respective residues are $-1$ and $1$.  By the residue theorem, therefore, the integral is zero and the two original integrals are equal.
A: Split the integral into two terms with limit $\left[0,\frac{\pi}{2}\right]$ and $\left[\frac{\pi}{2},\pi\right]$
\begin{align}
\int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x =\int_0^{\pi/2} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x +\int_{\pi/2}^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x \\
\end{align}
Using identity
\begin{align}
\int_a^{b} f(x) \,\mathrm{d}x = \int_a^{b} f(a+b-x) \,\mathrm{d}x 
\end{align}
Also the facts that $\cos\left(\frac{\pi}{2}-x\right)=\sin x$, $\sin\left(\frac{\pi}{2}-x\right)=\cos x$, $\cos\left(\frac{3\pi}{2}-x\right)=-\sin x$, and $\sin\left(\frac{3\pi}{2}-x\right)=-\cos x$, we get
\begin{align}
\int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x &=\int_0^{\pi/2} \frac{(\sin x)^2}{1 + \sin x \cos x} \,\mathrm{d}x +\int_{\pi/2}^{\pi} \frac{(-\sin x)^2}{1 + \sin x \cos x} \,\mathrm{d}x \\
&=\int_0^{\pi} \frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x\tag{1}
\end{align}

Let
\begin{align}
I=\int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x
\end{align}
Since
\begin{align}
\int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x =\int_0^{\pi} \frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x
\end{align}
then
\begin{align}
2I&=\int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x +\int_0^{\pi} \frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x\\
&=\int_0^{\pi} \frac{(\cos x)^2 + (\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x\\
I&=\frac{1}{2}\int_0^{\pi} \frac{1}{1 + \cos x \sin x} \,\mathrm{d}x\tag{2}
\end{align}

Using $(2)$, we get
\begin{align}
I&=\int_0^{\pi} \frac{1}{2 + 2\cos x \sin x} \,\mathrm{d}x\\
&=\int_0^{\pi} \frac{1}{2 + \sin (2x)} \,\mathrm{d}x\qquad\Rightarrow\qquad x\mapsto2x\\
&=\frac{1}{2}\int_0^{2\pi} \frac{1}{2 + \sin x} \,\mathrm{d}x\tag{3}
\end{align}
A: A quick hint is noticing the symmetry. A rigorous proof is that $$\int\limits_a^b {\frac{{f(\cos x)}}{{g(\sin x\cos x)}}dx}  = \int\limits_a^b {\frac{{f\left( {\sin \left( {\frac{\pi }{2} - x} \right)} \right)}}{{g\left( {\cos \left( {\frac{\pi }{2} - x} \right)\sin \left( {\frac{\pi }{2} - x} \right)} \right)}}dx}  = \int\limits_{\frac{\pi }{2} - b}^{\frac{\pi }{2} - a} {\frac{{f\left( {\sin u} \right)}}{{g\left( {\cos u\sin u} \right)}}du} $$Hope it helps ;)
A: The integrands are both periodic with period $\pi$, so it suffices to verify the identity over any interval of length $\pi$, including $\left[-\frac{\pi}{2}, \frac{\pi}{2}\right]$. Then, since both integrands are even functions, it suffices to check that the identity holds when integrating over $\left[0, \frac{\pi}{2}\right]$, that is, that
$$ \int_0^{\frac{\pi}{2}} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x =\int_0^{\frac{\pi}{2}} \frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x.$$
But one can show this simply by substituting $x = \frac{\pi}{2} - u$ on either side.
A: $$
\frac{\cos(\pi/2-x)^2}{1+\cos(\pi/2-x)\sin(\pi/2-x)} =
\frac{\sin(x)^2}{1+\sin(x)\cos(x)}
$$
A: 
$$I=\int_0^{\pi} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x$$
  $$J=\int_0^{\pi/2} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x$$


Use $\int_a^b f(x)dx=\int_a^nf(a+b-x)dx$ and $\int_0^{2a}f(x)dx=\int_0^a f(x)dx+f(2a-x)dx$

$$I=\int_0^{\pi/2} \frac{(\cos (\pi-x))^2}{1 + \cos (\pi-x) \sin (\pi-x)} \,\mathrm{d}x+\frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x$$
$$I=\int_0^{\pi/2} \frac{(\cos x)^2}{1 - \cos x \sin x} \,\mathrm{d}x+\frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x$$
$$I=\int_0^{\pi/2} \frac{(\cos (\pi/2-x))^2}{1 - \cos (\pi/2-x) \sin (\pi/2-x)} \,\mathrm{d}x+\frac{(\cos (\pi/2-x))^2}{1 + \cos (\pi/2-x) \sin (\pi/2-x)} \,\mathrm{d}x$$
$$I=\int_0^{\pi/2} \frac{(\sin x)^2}{1 - \sin x \cos x} \,\mathrm{d}x+\frac{(\sin x)^2}{1 + \cos x \sin x} \,\mathrm{d}x$$
$$I=\int_0^{\pi/2} \frac{(\sin x)^2}{1 - \sin x \cos x} \,\mathrm{d}x+\frac{(\sin (\pi-x))^2}{1 - \cos (\pi-x) \sin(\pi-x)} \,\mathrm{d}x$$
$$I=\int_0^{\pi} \frac{(\sin x)^2}{1 - \sin x \cos x} \,\mathrm{d}x$$

Hope you can now show that:
$$J=\int_0^{\pi/2} \frac{(\cos x)^2}{1 + \cos x \sin x} \,\mathrm{d}x=\int_0^{\pi/2} \frac{(\cos (\pi/2-x))^2}{1 + \cos (\pi/2-x) \sin (\pi/2-x)} \,\mathrm{d}x=\int_0^{\pi/2} \frac{(\sin x)^2}{1 + \sin x \cos x} \,\mathrm{d}x$$
