Minimizing a functional with a free boundary condition 
Find the extremals of the functional
$$\text{J}(y)=  y^2(1)  + \int_0^1 y'^2(x)dx   , \qquad y(0)=1.$$
Answer: $y(x)=1-\frac{1}{2}x$.

My solution:
$$ F (x,y,y')=y'^2(x).$$
After solving the Euler Lagrange equation we get $$\frac{\mathrm{d}}{\mathrm{d}x}(2y')=0.$$
Which implies that $$y=\frac{a}{2}x+b,$$ using initial value condition we get $b=1$. Could you please help me find value of $a$?
 A: Note that we can  write $J$ as
$$J(y) = \int_0^1 \left(2 y(x)y'(x) + y'(x)^2\right) \ dx \, + \, y(0)^2$$
Setting aside the constant $y(0)^2 = 1$ for now, we have $J$ as the integral of a function $F(y,y',x)$ where $F(y,y',x) = 2yy' + y'^2$.
You can now deploy your box of tricks on $F$ to find $y$. That is, the Euler-Lagrange equation:
$$0 = \frac{d \ }{dx} \frac{\partial F}{\partial y'} - \frac{\partial F}{\partial y} = \ ... $$
A: Hints:

*

*If one varies infinitesimally the functional
$$J[y]~:=~y(1)^2 + \int_0^1\! dx~ y^{\prime}(x)^2\tag{1}$$
without discarding boundary contributions, one finds
$$\begin{align} \delta J[y]~=~~~~~& 2 y(1)~\delta y(1) + 2\int_0^1\! dx~ y^{\prime}(x) ~\delta y^{\prime}(x)\cr
\stackrel{\text{int. by parts}}{=}& 2\left[ y(1) + y^{\prime}(1)\right] \delta y(1)  -2 y^{\prime}(0)~\underbrace{\delta y(0)}_{=0} - 2\int_0^1\! dx~ y^{\prime\prime}(x) ~\delta y(x).\end{align} \tag{2}$$


*Besides the given boundary condition $y(0)=1$, one concludes from formula (2) that a stationary configuration must obey
$$ y(1) + y^{\prime}(1)~=~0\qquad\text{and} \qquad\forall x\in [0,1]:y^{\prime\prime}(x)~=~0.\tag{3}$$
A: Your approach is correct, but it could be expressed more precisely. The first step is to replace the free boundary problem by a more familiar variational problem: find
$$
M(c) = \inf\left\{\int_0^1 (y'(x))^2\,dx :  y(0)=1, \ y(1)=c \right\}\tag{1}
$$
Having found $M(c)$, you can minimize $c^2+M(c)$ over all $c\in\mathbb{R}$ and thus obtain the minimum of functional $J$. 
The Euler-Lagrange equation for $(1)$ is $y''=0$, which leads to the minimizer $y(x) = 1+(c-1)x$ and subsequently $M(c) = (c-1)^2$.
Then $c^2+M(c) = c^2+(c-1)^2 $ is minimized at $ c= 1/2$, which delivers $\min J = 1/2$, attained by $y(x) = 1-x/2$.
