TITLE: For what interval of $a$ is $\int_0^{\frac\pi2}\frac{\cos a\sin x}{1+\sin a\sin x}dx =a\csc a-\frac\pi2\tan \frac a2$ valid?
QUESTION [6 upvotes]: In my previous Question [1], @Quanto has defined
$$J(a) = \int_0^{\frac\pi2}\ln(1+\sin a\sin x)\,dx$$
and stated
$$J'(a)
=\int_0^{\frac\pi2}\frac{\cos a\sin x}{1+\sin a\sin x}\,dx
=a\csc a-\frac\pi2\tan \frac a2
$$
But, I was wondering if this is valid $\forall a\in \Bbb R-{{n\pi}}$.
Using Desmos, it seems that this is valid for $a\in \Big(-\frac{3\pi}{2},\frac{\pi}{2}\Big)$. Is there any explanation can we offer?
On desmos, I run $a$ from $-1000$ to $1000$ and I see that the the Integral $\Big(J'(a)\Big)$ achieves value only from $-\pi$ to $\pi$.

REPLY [2 votes]: Note
\begin{align}
I=\int_0^{\frac\pi2}\frac{\cos a\sin x}{1+\sin a\sin x}dx
= \cot a\left( \frac\pi2 - \int_0^{\frac\pi2}\frac{1}{1+\sin a\sin x}dx\right)\tag1\\
\end{align}
With $\cos x= \frac{1-\tan^2\frac x2}{1+\tan^2\frac x2}$
\begin{align}& \int_0^{\frac\pi2}\frac{1}{1+\sin a\sin x}dx 
=\int_0^{\frac\pi2}\frac{1}{1+\sin a\cos x}dx \\
= &\>2\int_0^{\frac\pi2}\frac{d(\tan\frac x2)}{(1-\sin a)\tan^2\frac x2+(1+\sin a)}\\
= &\>2\sec a \tan^{-1}\left(\tan(\frac\pi4 -\frac a2)\right) 
=\>\sec a \>\left(\frac\pi2 -a \right)\tag2\\
\end{align}
where the last step requires $\frac\pi4 -\frac a2\in (-\frac\pi2,\frac\pi2)$, or $a\in ( - \frac\pi2, \frac{3\pi}2)$.
Substitute (2) into (1) to arrive at
$$I=a\csc a-\frac\pi2\tan \frac a2$$