Find function to make maximum value Let ${f : [0, 1] \rightarrow [-1, 1] }$ is a continuous function such that ${ \int_{0}^{1} x f \left(x\right) dx =0}$
Find $f(x)$ such that ${ \int_{0}^{1} \left(x ^{2 } + \frac{1}{4} \right) f \left(x\right) dx}$ has the maximum value.
 A: Disregard continuity.  Take $f = -1 + g$ so $0 \le g \le 2$ and you want to maximize $F = \int_0^1 (x^2+1/4) (g(x)-1)\ dx$ subject to $C = \int_0^1 x g(x) \ dx = \int_0^1 x\ dx = 1/2$.  Since $x^2+1/4$ is strictly convex while $x$ is linear, if you have a bit of "mass" somewhere in $(0,1)$, you can increase $F$ while keeping $C$ the same if you by splitting it up and moving half of it to the right and the other half to the left, by equal distances.  So an optimal solution must have $g$ of the form
$$g(x) = \cases{2 & for $x \le a$\cr
                0 & for $a < x \le b$\cr
                2 & for $b < x \le 1$\cr}$$
where $0 \le a \le b \le 1$, or 
$$f(x) = \cases{1 & for $x \le a$\cr
                -1 & for $a < x \le b$\cr
                1 & for $b < x \le 1$\cr}$$
This makes $C =  a^2 + 1 - b^2$ so $a^2 - b^2 = -1/2$, and $F = \dfrac{2}{3} (a^3-b^3) + \dfrac{1}{2}(a-b) + \dfrac{7}{12}$.  Using Lagrange multipliers I get 
$$ a=\frac{1}{2}\,\sqrt {\sqrt {2}-1},\ b=\frac{  1+\sqrt {2}
 }{2} \sqrt {\sqrt {2}-1}$$
With continuous functions, you can't attain a maximum but you can get arbitrarily close.
