Extremizing a functional subject to an equality constraint Question at hand is:

Let $y\in\cal C^2([0,\pi])$ satisfying $y(0)=y(\pi)=0$ and $\int_0^\pi y^2(x)dx=1$ extremize the functional 
  $$J(y)=\int_0^\pi\left(y'(x)\right)^2dx$$

It's an MCQ, and from options using initial conditions, I could easily infer that solutions are $y(x)=\pm\sqrt{2\over\pi}\sin x$ (the other two wrong options being $y(x)=\pm\sqrt{2\over\pi}\cos x$.
But Euler-Lagrange (only method I know to find extremals of functionals) leads me to $2y''(x)=0$. What am I missing/how to solve it directly?
 A: Since $C^2(0,\pi)\subset L^2(0,\pi)$, we may assume that
$$ y(x) = \sum_{n\geq 1} a_n \sin(nx) \tag{1}$$
holds, with the constraint $\sum_{n\geq 1}a_n^2 = \frac{2}{\pi}$ given by Parseval's theorem. It also gives:
$$ \int_{0}^{\pi}y'(x)^2\,dx = \frac{\pi}{2}\sum_{n\geq 1}n^2 a_n^2\color{red}{\geq} \frac{\pi}{2}\sum_{n\geq 1}a_n^2 = 1\tag{2} $$
and equality holds iff $a_n=0$ for every $n\geq 2$, so the only extremal  functions are $\color{red}{\pm\sqrt{\frac{2}{\pi}}\sin(x)}$.
This is just an instance of Wirtinger's inequality.
A: Hint: You have $F(x,y,y')=(y'(x))^2$ and $\int_{a}^{b}G(x,y,y')dx=\int_{0}^{\pi}y^2(x)dx=1...(*)$. Now solve this 
$$F_y+\lambda G_y-\frac{d}{dx}(F_y'+\lambda G_y')=0.$$ Once you get the $y(x)$, substitute back to $(*)$. Then you will get the result after simplification.
Result: Given the functional $J(y)=\int_{a}^{b}F(x,y,y')dx.$ Let the admissible curves satisfy the condition $y(a)=A$ and $y(b)=B$, $K(y)=\int_{a}^{b}G(x,y,y')dx=l$ where $K(y)$ is another functional and let $J(y)$ has extremum for $y=y(x)$ then if $y=y(x)$ is not an extremal of $K(y)$, there exists a constant $\lambda$ such that $y=y(x)$ is an extremal of the functional $\int_{a}^{b}(F+\lambda G)dx$ that is $y=y(x)$ satisfies $F_y+\lambda G_y-\frac{d}{dx}(F_y'+\lambda G_y')=0.$
A: The augmented functional is
$$\displaystyle\int_0^{\pi} \left( (y' (x))^2 + \lambda y^2 (x) \right)\mathrm{d}x$$
The Euler-Lagrange equation gives us the 2nd order ODE
$$y'' (x) = \lambda \, y (x)$$
whose solution is of the form
$$y (x) = c_1 \exp (\sqrt{\lambda} \, x) + c_2 \exp (-\sqrt{\lambda} \, x)$$
The boundary condition $y (0) = 0$ gives us $c_1 + c_2 = 0$. Hence, the solution is of the form
$$y (x) = \beta \sinh (\sqrt{\lambda} \, x)$$
However, the other boundary condition is $y (\pi) = 0$. As the hyperbolic sine has only one zero, then $\lambda < 0$. Thus, the solution is of the form
$$y (x) = \beta \sin (k \, x)$$
The boundary condition $y (\pi) = 0$ gives us the integrality constraint $k \in \mathbb Z$. The equality constraint 
$$\displaystyle\int_0^{\pi} y^2 (x) \, \mathrm{d}x = 1$$
gives us $\beta = \pm \sqrt{\frac{2}{\pi}}$. Hence, the solution is
$$y (x) = \pm \sqrt{\frac{2}{\pi}} \sin (k \, x)$$
Evaluating the original functional,
$$\displaystyle\int_0^{\pi} (y' (x))^2 \, \mathrm{d}x = k^2$$
The functional is minimized when $k = 0$, which yields the zero solution. Though the boundary conditions are obviously satisfied, the equality constraint cannot be satisfied. Thus, the functional is minimized when $k= \pm 1$, and the minimal function is
$$y (x) = \pm \sqrt{\frac{2}{\pi}} \sin (x)$$
