Euler-Lagrange equations for dependent multiple functions 
Find the extremals for the functional:
  $$
J(x) = \int_{0}^{1}\left[x\left(t\right)\dot{x}\left(t\right) + \ddot{x}^{2}\left(t\right)\right]\mathrm{d}t
$$
  where $x(0)=0$, $\dot{x}(0)=1$, $x(1)=2$, $\dot{x}(1)=4$.
Let $y(t)=[x(t)$ $\dot{x}(t)]^T$. Reexpress the functional in terms of $y(t)$ and solve the problem.

I can find the solution without doing that transformation. But, I cannot find the same solution when I transformed the functional.
 A: *

*The simplest is probably to notice that the first term $x\dot{x}=\frac{d(x^2/2)}{dt}$ is a total derivative, so we can rewrite the functional as a functional of $y\equiv\dot{x}$ only:
$$ J[y]~=~ 2 + \int_0^1\!\mathrm{d}t ~ \ddot{x}^2
~=~2 + \int_0^1\!\mathrm{d}t ~ \dot{y}^2. $$

*However, there is still a constraint
$$ 2~=~x(1)-x(0)~=~\int_0^1\!\mathrm{d}t ~\dot{x}~=~\int_0^1\!\mathrm{d}t ~y.$$

*So the new functional reads
$$ J[y]+\lambda \left(2-\int_0^1\!\mathrm{d}t ~y\right). $$
The Euler-Lagrange (EL) equation becomes
$$ 2\ddot{y}+\lambda ~=~0,$$
with solution 
$$y(t)~=~-\frac{\lambda}{4} t^2 + at+b.$$ 

*This should satisfy
$$2~=~\int_0^1\!\mathrm{d}t ~y~=~-\frac{\lambda}{12}  + \frac{a}{4}+b, $$
together with boundary conditions (BCs)
$$ y(0)~=~1\qquad\text{and}\qquad y(1)~=~4, $$
i.e.
$$ y(t)~=~3t^2+1.$$
This can be integrated to yield $x(t)$ itself.
A: $$
J = \int_0^1 G(x,\dot x, \ddot x) dt
$$
This problem is equivalent to
$$
J = \int_0^1 \left(G(x, y, \dot y)+\lambda(t)(y - \dot x)\right)dt,\ \ \mbox{s. t. } y = \dot x
$$
The Euler-Lagrange equations are
$$
\begin{cases}
G_x + \dot \lambda(t) & = & 0\\
G_y + \lambda(t)-\frac{d}{dt}G_{\dot y} & = & 0
\end{cases}
$$
or
$$
\begin{cases}
y + \dot\lambda(t) & = & 0\\
x +\lambda(t)-2 \ddot y & = & 0
\end{cases}
$$
or equivalently
$$
\begin{cases}
\dot x +\dot\lambda & = & 0\\
x+\lambda-2\dddot x & = &  0
\end{cases}
$$
Solving for $x, \lambda$ we will have the extremal $x(t) = t+t^3$
