# Maximizing a functional of two functions.

I am trying to maximize the functional $$J[u,v] = \frac{4}{L} \int_0^L f(u,v) \ dx = \frac{4}{L} \int_0^L u(v- \bar v)^2 + v(u-\bar u)^2 \ dx,$$ where $$0 \le u,v \le 1$$ and, $$\bar u = \frac{1}{L} \int_0^L u \ dx, \quad \bar v = \frac{1}{L} \int_0^L v \ dx.$$ The E-L equations here I believe are simply $$f_u = f_v = 0$$. This seems to imply that $$f_u = (v - \bar v)^2 + 2 v(u - \bar u)(1 - 1) = 0$$ since $$\frac{\partial \bar u}{\partial u} = 1$$, so that $$v = \bar v$$. Similarly we have $$u = \bar u$$. This obviously is the minimum of the functional, but is there a way to find the maximum (aside from guessing)?

Unless I am making a silly mistake, I am not sure you derived the correct Euler-Lagrange equations. The Euler-Lagrange equations also hold at a maximum point, not just at a minimum. Also keep in mind that the maximum may not exist. Another important point is that you have the constraints $$0\leq u,v\leq1$$ and so you do not always have the Euler-Lagrange equations. Say that $$(u_{0},v_{0})$$ is a point where you reach a maximum. Assume that there exist a measurable set $$E\subset\lbrack0,L]$$ and $$\varepsilon>0$$ such that $$\varepsilon\leq u_{0}(x),v_{0}(x)\leq1-\varepsilon$$ for all $$x\in E$$. This is the lucky case because you can take any pair of functions $$u,v$$ which are bounded and zero outside of $$E$$. Then for $$t$$ small you will have that $$0\leq u_{0}+tu\leq1$$, $$0\leq v_{0}+tv\leq1$$ and so you have that \begin{align*} g(t) & =J(u_{0}+tu,v_{0}+tv)\\ & =\frac{4}{L}\int_{0}^{L}(u_{0}+tu)\left( v_{0}+tv-\frac{1}{L}\int_{0} ^{L}(v_{0}+tv)\,dy\right) ^{2}+(v_{0}+tv)\left( u_{0}+tu-\frac{1}{L}\int _{0}^{L}(u_{0}+tu)\,dy\right) ^{2}dx\\ & \leq J(u_{0},v_{0})=g(0) \end{align*} which means that $$g^{\prime}(0)=0$$, that is \begin{align*} 0 & =g^{\prime}(0)=\frac{4}{L}\int_{0}^{L}u\left( v_{0}-\bar{v}_{0}\right) ^{2}+v\left( u_{0}-\bar{u}_{0}\right) ^{2}dx\\ & +\frac{4}{L}\int_{0}^{L}u_{0}2\left( v_{0}-\bar{v}_{0}\right) \left( v-\frac{1}{L}\int_{0}^{L}v\,dy\right) +v_{0}2\left( u_{0}-\bar{u} _{0}\right) \left( u-\frac{1}{L}\int_{0}^{L}u\,dy\right) dx\\ & =\frac{4}{L}\int_{0}^{L}u\left[ \left( v_{0}-\bar{v}_{0}\right) ^{2}+v_{0}2\left( u_{0}-\bar{u}_{0}\right) -\frac{1}{L}\int_{0}^{L} v_{0}2\left( u_{0}-\bar{u}_{0}\right) dy\right] dx\\ & +\frac{4}{L}\int_{0}^{L}v\left[ \left( u_{0}-\bar{u}_{0}\right) ^{2}+u_{0}2\left( v_{0}-\bar{v}_{0}\right) -\frac{1}{L}\int_{0}^{L} u_{0}2\left( v_{0}-\bar{v}_{0}\right) dy\right] dx, \end{align*} where I used Fubini's theorem. This is true for all bounded functions $$u$$, $$v$$ which are zero outside $$E$$ and so you get that \begin{align*} \left( v_{0}-\bar{v}_{0}\right) ^{2}+v_{0}2\left( u_{0}-\bar{u}_{0}\right) -2\overline{u_{0}v_{0}}+2\bar{u}_{0}\bar{v}_{0} & =0,\\ \left( u_{0}-\bar{u}_{0}\right) ^{2}+u_{0}2\left( v_{0}-\bar{v}_{0}\right) -2\overline{u_{0}v_{0}}+2\bar{u}_{0}\bar{v}_{0} & =0 \end{align*} for a.e. $$x\in E$$. These equations hold as long as $$\varepsilon\leq u_{0}(x),v_{0}(x)\leq1-\varepsilon$$. By taking $$\varepsilon=\frac{1}{n}$$ you get that these equations hold in the set $$E_{0}:=\{x\in\lbrack0,L]:\,0.
On the other hand, if on a set $$F_{0}$$ you have that $$u_{0}=0$$, then the variation $$u_{0}+tu$$ is only allowed if $$tu\geq0$$ in $$F_{0}$$. Say that $$t>0$$, then necessarily $$u\geq0$$ in $$F_{0}$$. This gives $$\frac{g(t)-g(0)}{t}\leq0$$ (since $$t>0$$), and so letting $$t\rightarrow0^{+}$$ you get $$g^{\prime}(0)\leq 0$$. In this case you only get the inequality $$\left( v_{0}-\bar{v}_{0}\right) ^{2}+v_{0}2\left( 0-\bar{u}_{0}\right) -2\overline{u_{0}v_{0}}+2\bar{u}_{0}\bar{v}_{0}=\left( v_{0}-\bar{v} _{0}\right) ^{2}+v_{0}2\left( u_{0}-\bar{u}_{0}\right) -2\overline {u_{0}v_{0}}+2\bar{u}_{0}\bar{v}_{0}\leq0$$ in $$F_{0}$$. To see what happens to the second equation, you have to consider the subsets of $$F_{0}$$ where $$0 (here you will get equality), where $$v_{0}=0$$ (here you will get $$\leq0$$), and where $$v_{0}=1$$ (so you to take $$v\leq0$$, which will give $$\geq0$$).
Then you have to consider the set $$F_{1}$$ where $$u_{0}=1$$ and so something similar.