Extremising a functional with boundary conditions (Euler-Lagrange) I need to determine all functions $ u(x) $ that extremise the functional: $$ I[u]= \int_{-\infty}^\infty \left[\frac{(u')^2}{2}+(1-\cos u)\right] \, dx $$
subject to the boundary conditions 
$$ \lim_{x \to -\infty} u(x)=0 $$ and $$ \lim_{x \to \infty} u(x) = 2\pi $$
I used the standard approach for finding the stationary points of a functional; that is, attempting to solve the Euler-Lagrange equation, but assuming I've attempted this correctly I arrive at 
$$ \frac{d^2u}{dx^2} = \sin u $$
which I believe is not (easily) directly solvable, so I'm presuming there's either another way to approach this problem or I've messed up somewhere. A point in the right direction would be great, thanks in advance
 A: $\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{\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{equation}
\lim_{x \to -\infty}\,\mrm{u}\pars{x} = 0\,,\qquad
\lim_{x \to \infty}\,\mrm{u}\pars{x} = 2\pi\label{1}\tag{1}
\end{equation}

Multiply both sides of your differential equation
$\ds{\totald[2]{\mrm{u}}{x} = \sin\pars{\mrm{u}}}$ by
$\ds{\totald{\mrm{u}}{x}}$:
\begin{align}
&\totald{\mrm{u}}{x}\,\totald[2]{\mrm{u}}{x} =
\totald{\mrm{u}}{x}\,\sin\pars{\mrm{u}}
\implies
{1 \over 2}\bracks{\totald{\mrm{u}}{x}}^{2} =
-\cos\pars{\mrm{u}} + \mc{E} + 1\ \mbox{where}\
\,\mc{E}\ \mbox{is a}\ constant.
\end{align}

Also,
\begin{align}
{1 \over 2}\bracks{\totald{\mrm{u}}{x}}^{2} & =
2\sin^{2}{u \over 2} + \,\mc{E}
\implies
\totald{u}{x} = \pm\root{2\,\mc{E} + 2\sin^{2}\pars{u \over 2}}
\\[5mm] \implies
\pm\int{\dd u \over \root{2\,\mc{E} + 2\sin^{2}\pars{u/2}}} &= x + \,\mc{C}\,,\quad\mc{C}\ \mbox{is a}\ constant.
\end{align}
Note that the integral is related to the Elliptic Integral $\,\mrm{F}\pars{\phi,k}$. Now, you have to manage to find $\ds{\,\mc{E},\ \mc{C}}$ and the 'suitable' sign $\ds{\pm}$ by using the boundary conditions \eqref{1}.
