# How to approach the following problem

Let $$f:[0,1]\to\mathbb{R}$$ be a continuous function then the maximum value of $$\int_0^1 f(x)x^2 \,\text{d}x -\int_0^1x(f(x))^2\,\text{d}x$$ for all such function(s) is? I first thought differentiating it but the limits are not variable so no use then I spent a lot of time thinking over it but literally have no idea how to begin. Please help.

Hint:

$$f(x)x^2 -xf(x)^2 = xf(x) ( x-f(x))$$

Think of $$f(x-f)$$ as a quadratic in $$f$$. Complete the square to get $$\frac{x^2}{4} - \left(f-\frac x2\right)^2$$

So, your integral is $$\int_0^1 \frac{x^3}{4} - x\left(f(x) -\frac x2\right)^2 dx$$

What function $$f$$ maximizes this?

• @ Tavish thanks a lot for your support.:-) Mar 4, 2021 at 14:10
• @sameedhussain Of course. Mar 4, 2021 at 14:23

Seems like functioncal calculus to me:

We want to optmize:

$$g[f] = \int_0^1 \left[ f(x)x^2 - x f^2 (x) \right]dx$$

Add a peturbation to $$g$$: $$g[f+ \epsilon] = \int_0^1 \left[ (f + \epsilon)x^2 - x (f+\epsilon)^2 \right] dx$$

It is easy to find that terms of order $$\epsilon$$ are:

$$\epsilon \int_0^1 \left[x^2 - 2 xf \right] dx$$

So, for the minimum condition, this term in bracket must be zero, which makes our function as:

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

Now you can integrate easily

$$f(x+h) = f(x) + h f'(x) + \text{junk}$$
Now, if you are at maxima then $$f'(x)=0$$ and hence if you increase $$h$$ by some teeny amount, the function doesn't change much. Similar notion here though more abstract.
Another notion is that, similar to how we neglect term of $$dx^2$$, we neglect terms of $$\epsilon^2$$ saying they are tinnier than tiny petrubations.