Evaluating $\int_{0}^{\pi} \frac{1}{\sqrt{u^2+2u\cos x +1}} \mathrm{d}x$ 
Does the integral $$\int_0^{\pi} \frac{1}{\sqrt{u^2+2u\cos x +1}} \text d x \hspace{30pt} (u \le 1) $$ has a closed form? If it has, how do we evaluate it?

I was solving a physics problem which I have asked on physics SE as well (here), and this integral popped out. How do I solve it?
 A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\bbox[5px,#ffd]{\left.\int_{0}^{\pi}{\dd x \over
\root{u^{2} + 2u\cos\pars{x} +1}}
\right\vert_{\, u\ \leq\ 1}}
\\[5mm] = &\
{1 \over 2}\int_{-\pi}^{\pi}{\dd x \over
\root{u^{2} + 2u\cos\pars{x} +1}}
\\[5mm] = &\
{1 \over 2}\int_{-\pi}^{\pi}{\dd x \over
\root{\pars{u + \expo{\ic x}}\pars{u +
\expo{-\ic x}}}}
\\[5mm] = &\
{1 \over 2}\,\Re\oint_{\verts{z} = 1}
{\dd z/\pars{\ic z} \over
\root{\pars{u + z}\pars{u + 1/z}}}
\\[5mm] = &\
{1 \over 2\root{u}}\,\Im\oint_{\verts{z} = 1}
{\dd z \over
\root{z}\root{z + u}\root{z + u^{-1}}}
\\[5mm] = &\
-{1 \over 2\root{u}}\ \times
\\[2mm] &
\Im\int_{-1}^{-u}
{\dd z \over
\pars{\root{-z}\expo{\ic\pi/2}}
\pars{\root{-z - u}\expo{\ic\pi/2}}\root{z + u^{-1}}}
\\[2mm] &
\,\,\,-{1 \over 2\root{u}}\ \times
\\[2mm] &\
\Im\int_{-u}^{0}
{\dd z \over
\pars{\root{-z}\expo{\ic\pi/2}}
\root{z + u}\root{z + u^{-1}}}
\\[2mm] &
\,\,\,-{1 \over 2\root{u}}\ \times
\\[2mm] &\
\Im\int_{0}^{-u}
{\dd z \over
\pars{\root{-z}\expo{-\ic\pi/2}}
\root{z + u}\root{z + u^{-1}}}
\\[2mm] &
\,\,\,-{1 \over 2\root{u}}\ \times
\\[2mm] & \Im\int_{-u}^{-1}
{\dd z \over
\pars{\root{-z}\expo{-\ic\pi/2}}
\pars{\root{-z - u}\expo{-\ic\pi/2}}\root{z + u^{-1}}}
\\[5mm] = &\
{1 \over \root{u}}\int_{0}^{u}
{\dd z \over
\root{z}
\root{u - z}\root{u^{-1} - z}} =
\bbx{2\on{K}\pars{u^{2}}} \\ &
\end{align}
$\ds{\on{K}}$ is the
$\ds{\on{K}}$ Elliptic Function.

A: You'll need an elliptic integral for this. (I love them a lot. So much that I put together a whole monograph on them.)
Let the integral be $I(u)$. By symmetry we easily see that $I(u)=I(-u)$, so we may restrict to $u\ge0$. Byrd and Friedman 289.00 then gives
$$I(u)=\frac2{u+1}K\left(\frac{4u}{(u+1)^2}\right)$$
If $|u|<1$ this may be simplified by a descending Gauss transformation to just $2K(u^2)$. Note that I am using the parameter $m$ rather than the elliptic modulus $k=\sqrt m$.
A: If you are not too familiar with elliptic integrals or have problems to compute them, you could use
$$2\,K(u^2)=\pi\, \sum_{n=0}^\infty a_n u^{2n}$$ with
$$a_n=\Bigg[\frac{ (2 n)!}{2^{2 n}\,(n!)^2}\Bigg]^2$$ the computation being simple since
$$a_{n+1}=\frac{(2 n+1)^2}{4 (n+1)^2}\, a_n$$
For the case where $u$ is close to $1$, it is much better to use
$$2\,K(u^2)=\log \left(\frac{8}{1-u}\right)+\frac{1}{2} (u-1) \left(\log
   \left(\frac{1-u}{8}\right)+1\right)+\frac{1}{16} (u-1)^2 (-5 \log (1-u)-7+15
   \log (2))+\frac{1}{96} (u-1)^3 (21 \log (1-u)+34-63 \log (2))+\frac{(u-1)^4
   (-1014 \log (1-u)-1775+3042 \log (2))}{6144}+O\left((u-1)^5\right)$$ which is extremely good for $u \geq \frac 34$.
A: I prefer to write another answer for the case where $u>1$.
In the most general case,
$$\int_{0}^{\pi} \frac{1}{\sqrt{u^2+2u\cos x +1}} \,dx=\frac{2 }{u-1}K\left(-\frac{4 u}{(u-1)^2}\right)$$ and we can expand the rhs as a series built around $u=1$. This would give
$$\frac{2 }{u-1}K\left(-\frac{4 u}{(u-1)^2}\right)=\sum_{n=0}^\infty a_n \, u^n$$ where the first $a_n$'s are
$$\left\{d,\frac{1}{2}-\frac{d}{2},\frac{5 d}{16}-\frac{7}{16},\frac{17}{48}-\frac{7
   d}{32},\frac{169 d}{1024}-\frac{1775}{6144},\frac{14789}{61440}-\frac{269
   d}{2048},\frac{1781
   d}{16384}-\frac{100741}{491520},\frac{244835}{1376256}-\frac{3035
   d}{32768},\frac{338377
   d}{4194304}-\frac{276441853}{1761607680},\frac{1482803963}{10569646080}-\frac{59
   9569 d}{8388608}\right\}$$ where $d=\log \left(\frac{8}{u-1}\right)$.
Uisng the above terms, the result is quite decent up to $u=2$. For this value, the exact result is
$2 K(-8) \sim 1.68575$ while the expansion gives $1.68208$
