Evaluating $\int_{0}^{\pi} \frac{1}{\sqrt{u^2+2u\cos x +1}} \mathrm{d}x$

$\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.

enter image description here


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$.