Integrate $I(a) = \int_0^{\pi/2} \frac{dx}{1-a\sin x}$ 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.
 A: Observe that your integral is convergent in the usual sense for $|a|<1$. You may then write $t=\tan \dfrac{x}{2}$,  giving $ \sin x=\dfrac{2t}{1+t^2}$.
Hence
$$
\begin{align}
I(a) &= \int_0^{\pi/2} \frac{dx}{1-a\sin x}\\\\
&= 2\int_0^{1} \frac{1}{1-a\dfrac{2t}{1+t^2}}\frac{dt}{1+t^2}\\\\
&= 2\int_0^{1} \frac{1}{(t-a)^2+(1-a^2)}dt\quad \left(t-a=\sqrt{1-a^2}\:u,\,dt=\sqrt{1-a^2}\:du\right)\\\\
&= \frac{2}{\sqrt{1-a^2}}\int_{-a/\sqrt{1-a^2}}^{(1-a)/\sqrt{1-a^2}} \frac{1}{u^2+1}du\quad \\\\
&= \frac{2}{\sqrt{1-a^2}}\arctan \left(\sqrt{\frac{1+a}{1-a}}\right)
\end{align}
$$
A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\dsc}[1]{\displaystyle{\color{red}{#1}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,{\rm Li}_{#1}}
 \newcommand{\norm}[1]{\left\vert\left\vert\, #1\,\right\vert\right\vert}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$

With $\ds{\verts{a} < 1}$:

\begin{align}&\color{#66f}{\large\int_{0}^{\pi/2}{\dd x \over 1 - a\sin\pars{x}}}
=\int_{0}^{\pi/2}{1 + a\sin\pars{x} \over 1 - a^{2}\sin^{2}\pars{x}}\,\dd x
=\int_{0}^{\pi/2}{1 + a\sin\pars{x} \over 1 - a^{2} + a^{2}\cos^{2}\pars{x}}\,\dd x
\\[5mm]&=\int_{0}^{\pi/2}
{\sec^{2}\pars{x} \over \pars{1 - a^{2}}\sec^{2}\pars{x} + a^{2}}
\,\dd x
+\int_{0}^{\pi/2}{a\sin\pars{x} \over a^{2}\cos^{2}\pars{x} + 1 - a^{2} }\,\dd x
\\[5mm]&=\underbrace{\int_{0}^{\pi/2}
{\sec^{2}\pars{x} \over \pars{1 - a^{2}}\tan^{2}\pars{x} + 1}\,\dd x}
_{\ds{\dsc{y}\ \equiv \dsc{\root{1 - a^{2}}\tan\pars{x}}}}\ +\
{1 \over 1 - a^{2}}\ \underbrace{\int_{0}^{\pi/2}{a\sin\pars{x} \over  a^{2}\cos^{2}\pars{x}/\pars{1 - a^{2}} + 1}\,\dd x}
_{\ds{\dsc{z}\ \equiv\ \dsc{{\verts{a} \over \root{1 - a^{2}}}\,\cos\pars{x}}}}
\end{align}

Then,

\begin{align}&\color{#66f}{\large\int_{0}^{\pi/2}{\dd x \over 1 - a\sin\pars{x}}}
\\[5mm]&={1 \over \root{1 - a^{2}}}\int_{0}^{\infty}{\dd y \over y^{2} + 1}
- {\sgn\pars{a}\root{1 - a^{2}} \over 1 - a^{2}}
\int_{\verts{a}/\root{1 - a^{2}}}^{0}{\dd z \over z^{2} + 1}
\\[5mm]&={1 \over \root{1 - a^{2}}}\bracks{%
{\pi \over 2} + \sgn\pars{a}\arctan\pars{\verts{a} \over \root{1 - a^{2}}}}
\\[5mm]&=\color{#66f}{\large{1 \over \root{1 - a^{2}}}\bracks{%
{\pi \over 2} + \arctan\pars{a \over \root{1 - a^{2}}}}}
\end{align}
A: 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))$).
A: Using $u=\sin x$ and $v^2=\frac{1+u}{1-u}$
we have
\begin{eqnarray}
\int_0^{\frac{\pi}{2}}\frac{dx}{1-a\sin x}&=&\int_0^{1}\frac{1}{(1-au)\sqrt{1-u^2}}du\\
&=&\int_0^{1}\frac{1}{(1-au)(1+u)}\sqrt{\frac{1+u}{1-u}}du\\
&=&\int_1^\infty\frac{1}{(1-a\frac{v^2-1}{v^2+1})(1+\frac{v^2-1}{v^2+1})}v\frac{2v}{(1+v^2)^2}dv\\
&=&2\int_1^\infty\frac{1}{(1+a)+(1-a)v^2}dv\\
&=&\frac{2}{1-a}\int_1^\infty\frac{1}{v^2+\frac{1+a}{1-a}}dv\\
&=&\frac{2}{1-a}\sqrt{\frac{1-a}{1+a}}\arctan\left(\sqrt{\frac{1-a}{1+a}}v\right)\bigg|_1^\infty\\
&=&\frac{2}{\sqrt{1-a^2}}\left(\frac{\pi}{2}-\arctan\left(\sqrt{\frac{1-a}{1+a}}\right)\right)
\end{eqnarray}
