TITLE: Calculus of variation with inequality constraints
QUESTION [7 upvotes]: I want to find the function $y$ which maximizes the functional
$J[y] = \int_0^1 g(x) y(x) dx$
subject to $0 \leq y(x) \leq 1$ for all $x\in [0,1]$ and $\int_0^1 y(x) dx = k$ where $g$ is a strictly increasing function. 
I know that I can take care of the isoperimetric constraint quite easily using the Lagrangian
$K[y] = \int_0^1 (g(x) y(x) + \lambda y(x)) dx$.
I also know that I can take care of constraints of the form $y(x) \leq 1$ using a substitution such as $u^2(x) = 1 - y(x)\geq 0$ to get
$K[u] = \int_0^1 (g(x) (1-u^2(x)) + \lambda (1-u^2(x)))dx$.
However, I am quite at a loss with a constraint of the form $0 \leq y(x) \leq 1$, i.e., when two inequalities are involved at the same time. How can I take care of this?

REPLY [3 votes]: I think its better to write your constraint in this form:
$0 \leq y(x) \leq 1 \implies -\frac{1}{2} \leq y(x)-\frac{1}{2} \leq \frac{1}{2} \implies \left( y(x)-\frac{1}{2} \right)^2 \leq \frac{1}{4} \implies  y(x)^2-y(x)<0$. Now you can use your knowledge to solve the problem.
Good luck.