<s>[INST] 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?
 [/INST] 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}
</s>