TITLE: Evaluate $\int_{-\frac{\pi}{4}}^{\frac{\pi}{4}} \frac{\cos x+1-x^2}{(1+x\sin x)\sqrt{1-x^2}}dx$
QUESTION [5 upvotes]: $$\int_{-\frac{\pi}{4}}^{\frac{\pi}{4}} \frac{\cos x+1-x^2}{(1+x\sin x)\sqrt{1-x^2}}dx$$
which is W3,  Jozsef Wildt International Mathematical Competition 2019.

REPLY [7 votes]: A glance at the following equality
$$\frac{\cos x+1}{x\sin x+1}\mathrm{d}x=\frac{\mathrm{d}(x+\sin x)}{x\sin x+1}$$
inspires us to calculate that
$$\frac{\mathrm{d}}{\mathrm{d}x}\frac{x+\sin x}{x\sin x+1}=\frac{\cos x(\cos x+1-x^2)}{\left(x\sin x+1\right)^2}.$$
Let $y:=\frac{x+\sin x}{x\sin x+1}$, and compared with the integrand, we have
\begin{align*}
I& :=\int\frac{\cos x+1-x^2}{(1+x\sin x)\sqrt{1-x^2}}dx\\
& =\int\frac{x\sin x+1}{\cos x\sqrt{1-x^2}}\mathrm{d}y\\
& =\int\frac{x\sin x+1}{\sqrt{\left(1-x^2\right)\left(1-\sin^2 x\right)}}\mathrm{d}y.
\end{align*}
It's important to note that
\begin{align*}
\left(1-x^2\right)& \left(1-\sin^2 x\right)=\\
& \left(x\sin x+1\right)^2-\left(x+\sin x\right)^2.
\end{align*}
It follows that
\begin{align*}
I& =\int\left(1-\frac{\left(x+\sin x\right)^2}{\left(x\sin x+1\right)^2}\right)^{-\frac{1}{2}}\mathrm{d}y\\
& =\int\frac{\mathrm{d}y}{\sqrt{1-y^2}}=\arcsin y+C.
\end{align*}
Hence
\begin{align*}
I_1& :=\int_{-\frac{\pi}{4}}^{\frac{\pi}{4}} \frac{\cos x+1-x^2}{(1+x\sin x)\sqrt{1-x^2}}dx\\
& =2\arcsin\left(\frac{4+\pi\sqrt{2}}{\pi+4\sqrt{2}}\right).
\end{align*}