TITLE: Integrate $I(a) = \int_0^{\pi/2} \frac{dx}{1-a\sin x}$
QUESTION [6 upvotes]: I have a problem with this integral. It seems that solution has to be simple, but I couldn't find out.
$$I(a) = \int_0^{\pi/2} \frac{dx}{1-a\sin x}$$
I tried using integration by parts and differentiating with regard to a, but neither helped.

REPLY [2 votes]: The purpose of this reply is twofold. Firstly, I'd like to point out that the integral is convergent for all real $a<1$. Secondly, I'd like to show another possible way of calculating the integral.
Let $f(x)=1/(1-a\sin x)$. We calculate
$$
\int_0^{\pi/2}f(x)\, dx.
$$
If $0<a<1$ then $f$ is monotonically increasing on $(0,\pi/2)$ with values in 
$(1,1/(1-a))$. Its inverse $f^{-1}$ is given by 
$f^{-1}(x)=\arcsin\bigl(\tfrac{1}{a}\bigl(1-\tfrac{1}{x}\bigr)\bigr)$. 
We use the fact that (draw the graph!)
$$
\int_0^{\pi/2}f(x)\, dx + \int_{1}^{1/(1-a)} f^{-1}(x)\, dx = \frac{\pi}{2}\times \frac{1}{1-a}.
$$
(Another way here is to just use the substitution $y=1/(1-a\sin x)$.)
Integration by parts gives
\begin{align}
\int_{1}^{1/(1-a)} \arcsin\bigl(\tfrac{1}{a}\bigl(1-\tfrac{1}{x}\bigr)\bigr)\, dx 
&= \Bigl[x\arcsin\bigl(\tfrac{1}{a}\bigl(1-\tfrac{1}{x}\bigr)\bigr)\Bigr]_{1}^{1/(1-a)} \\
&\qquad - \int_{1}^{1/(1-a)} \frac{\sqrt{1-a^2}}{a\sqrt{1-\bigl(\frac{1-a^2}{a}x-\frac{1}{a}\bigr)^2}}\, dx\\
&=\Bigl[x\arcsin\bigl(\tfrac{1}{a}\bigl(1-\tfrac{1}{x}\bigr)\bigr)
-\tfrac{1}{\sqrt{1-a^2}}\arcsin\bigl(\tfrac{1-a^2}{a}x-\tfrac{1}{a}\bigr)
\Bigr]_{1}^{1/(1-a)}\\
&=\frac{\pi}{2}\times\frac{1}{1-a}-\frac{\pi+2\arcsin(a)}{2\sqrt{1-a^2}}.
\end{align}
Hence
\begin{equation}
\int_0^{\pi/2}\frac{1}{1-a\sin x}\, dx =\frac{\pi+2\arcsin(a)}{2\sqrt{1-a^2}}.\tag{*}
\end{equation}
If $-1<a<0$, then $f$ is monotonically decreasing from $1$ to $1/(1-a)$ on the
interval $(0,\pi/2)$. The same calculations as above (be a bit careful with the
limits of the integral!) gives $(*)$ again.
Finally, it is trivial that $(*)$ also holds for $a=0$.
The integral is, however, convergent also for $a\leq -1$. For $a<-1$, the same
calculations as above give
$$
\int_{0}^{\pi/2}\frac{1}{1-a\sin x}\, dx = \frac{\ln(-a+\sqrt{a^2-1})}{\sqrt{a^2-1}}.
$$
(This could also be expressed using the inverse hyperbolic sine, $\text{arsinh}$. If you know complex analysis this is not a problem.) 
Finally, for $a=-1$, the value of the integral is $1$. This can be seen either as a
limit of the previous expressions or by a direct calculation (it holds that
$\int 1/(1+\sin x)\, dx = 2\sin(x/2)/(\cos(x/2)+\sin(x/2))$).