Compute $\int \frac{\cos ^2x+\cos (\sin x)}{\sin x \sin (\sin x)+1} \, dx$ From software, I get
$$\int \frac{\cos ^2 x+\cos (\sin x)}{\sin x \sin (\sin x)+1} \, dx=-2 \tan ^{-1}\left(\cos \left(\frac{x}{2}-\frac{\sin x}{2}\right) \csc \left(\frac{x}{2}+\frac{\sin x}{2}\right)\right)$$
I tried  $t=\sin x,x=\arcsin t$ and get
$$\int \frac{1-t^2+\cos t}{\sqrt{1-t^2} (1+t \sin t)} \, dt$$
Then, I can't figure out how to do it.
 A: Rewrite the denominator
\begin{align}
 \sin x \sin (\sin x)+1 = &\frac12[\cos(x-\sin x) - \cos(x+\sin x)]+1
\\ = &\frac12[1-\cos(x+\sin x)]  + \frac12[1+\cos(x-\sin x)]
\\ = & \sin^2t_+  + \cos^2t_-
\end{align}
where $t_\pm=\frac x2 \pm \frac{\sin x}2$. Also rewrite the numeritor
\begin{align}
\cos ^2x+\cos (\sin x)= &\cos x\cos(t_+ + t_-) + \cos(t_+ - t_-)
\\ = &(1+\cos x)\cos t_+ \cos t_- + (1-\cos x)\sin t_+ \sin t_-
\\ = & 2 \cos t_- \frac{d\sin t_+}{dx} - 2\sin t_+ \frac{d\cos t_-}{dx}
\end{align}
Substitute above into the integrand to obtain
\begin{align}
\int \frac{\cos ^2 x+\cos (\sin x)}{\sin x \sin (\sin x)+1} \, dx
& =\int \frac {2 \cos t_- \frac{d\sin t_+}{dx} - 2\sin t_+ \frac{d\cos t_-}{dx} }{ \sin^2t_+  + \cos^2t_-} \\
& =-2\int \frac {\sin^2 t_+ \frac{d}{dx}\left(\frac{\cos t_-}{\sin t_+}\right) }{ \sin^2t_+  + \cos^2t_-} \\
& =-2\int \frac {\frac{d}{dx}\left(\frac{\cos t_-}{\sin t_+}\right) }{ 1 + \left(\frac{\cos t_-}{\sin t_+}\right)^2} 
 = -2\tan ^{-1}\left(\frac{\cos t_-}{\sin t_+}\right) +C
\end{align}
A: Because
$$\begin{align}
\left(\arcsin\frac{y+\sin y}{1+y\sin y}\right)'=\frac{1-y^2+\cos y}{(1+y\sin y)\sqrt{1-y^2}}
\end{align}$$
Then let y=sinx, Problem solved.
