TITLE: Minimizing a functional with a free boundary condition
QUESTION [5 upvotes]: Find the extremals of the functional 
  $$\text{J}(y)=  y^2(1)  + \int_0^1 y'^2(x)dx   , \ \ 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$?

REPLY [2 votes]: 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
$$ \delta J[y]~=~ 2 y(1)~\delta y(1) + 2\int_0^1\! dx~ y^{\prime}(x) ~\delta y^{\prime}(x)$$
$$~\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).\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\quad\text{and} \quad\forall x\in [0,1]:y^{\prime\prime}(x)~=~0.\tag{3}$$