Maximize $\int_0^1 x^2f(x)~\mathrm dx - \int_0^1 xf(x)^2~\mathrm dx$ among continuous $f:[0,1]\to\Bbb R$

Solution 1:

Here is another approach in the case we can't express the integral in the way you did (see the comment of @DanielFischer). Let $X=C([0,1])$ and $I:X\to\mathbb{R}$ be defined by $$I(f)=\int_0^1 x^2f(x)-\int_0^1xf(x)^2$$

Note that $I$ is a continuously differentiable function and $$\langle I'(f),g\rangle =\int_0^1 (x^2 g(x)-2xf(x)g(x)),\ \forall\ f,g\in X$$

We want to find $f\in X$ such that $$\langle I'(f),g\rangle=0,\ \forall\ g\in X$$

Therefore $$f(x)=\frac{x}{2}$$

To verify that $f$ is a maximum, note that $$I(f+h)=\int_0^1\left(\frac{x^3}{4}-xh(x)^2\right)$$