Calculate $\int_0^1 \frac{1}{\sqrt{x(1-x)}} dx$ using residue calculus I'd like to calculate $$\int_0^1 \frac{1}{\sqrt{x(1-x)}} dx,$$ using residue calculus. I was given a hint to consider the function $$f(z) = \frac{1}{z\sqrt{1-\frac{1}{z}}}. $$ I thought I was relatively comfortable solving residue calculus problems, until I saw this one. Because I am already stuck before I have even begun. 
I'm thinking that $f(z)$ is analytic when $z \neq 0$ and when $1-1/z > 0. $ I'm also assuming I should make a branch cut of some sort because of the aforementioned condition on $1-1/z$. But it occured to me that $1-1/z \leq 0$ precisely when $0 < z < 1$, and therefore this makes no sense to me since the limits of the integral that I am trying to solve are $0$ and $1$...
So in conclusion, I need a lot of help.  
 A: $\def\th{\theta}
\def\p{\pi}
\def\e{\varepsilon}
\def\g{\gamma}
\def\G{\Gamma}
\DeclareMathOperator{\sech}{sech}$Let 
\begin{align*}
z &= r_1 e^{i\th_1} \\
&= 1+r_2 e^{i\th_2}
\end{align*}
where $r_i>0$ and $0\le\th_i<2\p$. 
(Here we choose the branch cuts for the two roots and, with the restriction on $\th_i$, are examining the principal branch.)
Then 
\begin{align*}
g(z) &= \frac{1}{\sqrt{z(1-z)}} \\
&= \frac{1}{\sqrt{r_1 r_2}} e^{-i(\th_1+\th_2+\p)/2}.
\end{align*}
Let $0<\e\ll 1$. 
It is a straightforward exercise to show that the branch cut for $g(z)$ extends along the real line from $x=0$ to $x=1$ and that 
\begin{align*}
\lim_{\e\to 0^+} g(x+i\e) &= -\lim_{\e\to 0^+} g(x-i\e)
    = -\frac{1}{\sqrt{x(1-x)}}
    & \textrm{for }0<x<1.
\end{align*}
Let $\g = \sum_{i=1}^4 \g_i$ be the counterclockwise contour with 
\begin{align*}
\g_1 &: t-i\e, 
    t\in(0,1) \\
\g_2 &: 1+\e e^{i\th}, 
    \th\in[-\p/2,\p/2] \\
\g_3 &: 1-t+i\e,
    t\in(0,1) \\
\g_4 &: \e e^{i\th}, 
    \th\in[\p/2,3\p/2].
\end{align*}
One can show that $\int_{\g_2} = \int_{\g_4} = 0$ in the limit $\e\to 0^+$. 
(Note that, $\int_{\g_2}, \int_{\g_4}\sim \sqrt\e$.) 
Thus, in the limit $\e\to 0^+$, 
\begin{align*}
\int_\g &\to \int_{\g_1}+\int_{\g_3} \\
&= \int_0^1 g(t-i\e)dt + \int_0^1 g(1-t+i\e)dt \\
&= \int_0^1 g(t-i\e)dt - \int_0^1 g(t+i\e)dt \\
&\to 2\int_0^1 \frac{dx}{\sqrt{x(1-x)}}. 
\end{align*} 
Thus, 
$$\int_0^1 \frac{dx}{\sqrt{x(1-x)}} = \frac 1 2 \int_\g g(z)dz.$$ 
Now deform the contour to $\G: R e^{i\th}, \th\in[0,2\p)$, where $R>1$, and consider the limit $R\to\infty$.
One can show that, for large $|z|$, 
$g(z) = -i/z + O(1/z^2)$
and so 
$\int_\G g(z) dz = 2\p i(-i) = 2\pi$
in the limit $R\to\infty$. 
Thus, 
$$\int_0^1 \frac{dx}{\sqrt{x(1-x)}} = \p.$$
Avoiding branch cuts
Let $x = \frac{1}{2}(1+\tanh t)$. 
Then 
$$\int_0^1 \frac{dx}{\sqrt{x(1-x)}} = \int_{-\infty}^\infty \sech t\,dt.$$
In the spirit of the question we evaluate this integral using residue calculus. 
Note that 
\begin{align*}
\int_{-\infty}^\infty \sech t\,dt
&= \lim_{\e\to 0^+}\int_{-\infty}^\infty e^{i\e t}\sech t\,dt \\
&= \lim_{\e\to 0^+}\int_\g e^{i\e z}\sech z\,dz,
\end{align*}
where $\g$ encircles the poles in the upper half plane in a counterclockwise manner. 
The (simple) poles occur at $z = (2n+1)\p i/2$ for $n=0,1,\ldots$. 
It is a straightforward exercise to find the residues, 
$$\mathrm{Res}_{z=(2n+1)\p i/2} e^{i\e z}\sech z 
= (-1)^{n+1}i e^{-(2n+1)\p \e/2}.$$
Then 
\begin{align*}
\sum \mathrm{Res}\, e^{i\e z}\sech z
&= \sum_{n=0}^\infty (-1)^{n+1}i e^{-(2n+1)\p \e/2} \\ 
&= -i e^{-\p\e/2} \sum_{n=0}^\infty (-e^{-\p\e})^n \\ 
&= -\frac{i e^{\p\e/2}}{1+e^{\p\e}} \\
&\to -i/2.
\end{align*}
Thus, 
$$\int_0^1 \frac{dx}{\sqrt{x(1-x)}} = 2\pi i(-i/2) = \p.$$
