given $f:[0,1] \to \Bbb{R}$, find the maximum value of $$\int_0^1 x^2f(x) - xf^2(x) dx$$
I tried to factorize it as such: $$I = \int_0^1 xf(x) ( x - f(x) )dx$$ Then tried Cauchy-Schwarz $$\int_0^1 xf(x)(x-f(x))dx \le \sqrt{\int_0^1(xf(x))^2dx \cdot \int_0^1 (x-f(x))^2 dx}$$ RHS is maximum when $\int_0^1 (xf(x))^2 dx = \int_0^1 (x-f(x))^2 dx$. Solving this, $$\int_0^1x^2 f^2(x) dx= \int_0^1 x^2 + f^2(x) - 2xf(x)dx \\ \int_0^1 f^2(x)(1-x^2)-2xf(x)+x^2 dx = 0 \\ \int_0^1 f(x)(f(x)(1-x^2) + 2x) = -\frac 13$$ And I got stuck here. I think I'm just overcomplicating things with this method. Is there a simpler way to do this?
I don't know if you are aware of the Euler-Lagrange Identity, but that would solve this in one line. So for any integral of the form
$$J[f] = \int_{x_1}^{x_2} L(x,f(x), f'(x))dx$$
The minima or maxima will occur when $f$ satisfies the following differential equation
$$\frac{\partial L}{\partial f} - \frac{d}{dx}\frac{\partial L}{\partial f'} = 0$$
The derivation is quite well explained here, and should be easy enough to follow: https://en.wikipedia.org/wiki/Calculus_of_variations
So using this, with $L(x,f(x)) = x^2f(x) - xf^2(x)$,
$$\frac{\partial L}{\partial f} = x^2 - 2xf(x) = 0$$
Hence $f(x) = \frac{x}{2}$, and maximum value is $\frac{1}{16}$
Alternate Solution
Rewrite the integral as
$$I = \int_0^1x^3\left(\frac{f(x)}{x} - \left(\frac{f(x)}{x}\right)^2\right)dx$$ Let $\frac{f(x)}{x} = y(x)$
$$I = \int_0^1x^3y(1-y)dx$$
Now, tha maximum attainable value for $y(1-y)$ is when $y = \frac{1}{2}$
Hence, $$I \leq \int_0^1 \frac{x^3}{4}dx$$
With equality occuring only when $f(x) = \frac{x}{2}$