Suppose $ f $ is a continuous function from $ [0, 1] $ to $ [-1, 1] $ with $ |f(x)|\leq x, x\in [0, 1] $. Find the maximal value for $$ \left| \int_{0}^{1}(f(x))^2-f(x)dx \right| .$$
I have tried the following:
\begin{align*} \left| \int_{0}^{1}(f(x))^2-f(x)dx \right|&=\left| \int_{0}^{1}(f(x)-\frac{1}{2})^2-\frac{1}{4})dx \right| \\ &=\left| \int_{0}^{1}(f(x)-\frac{1}{2})^2dx-\frac{1}{4}\right| \end{align*} So we have to find some $ f(x) $ to make $ \int_{0}^{1}(f(x)-\frac{1}{2})^2dx $ as far from $ \frac{1}{4} $ as possible. Then I am stuck...
Let $A=\{f\in \mathcal C([0,1],[-1,1])\;,\; \forall x, |f(x)|\leq x\}$. It is not hard to prove that $$\sup_{f\in A}\left|\int_0^1f^2-f \right|= \max\left(\sup_{f\in A}\left[\int_0^1f^2-f\right], -\inf_{f\in A}\left[\int_0^1f^2-f\right] \right)$$
Besides, for $f\in A$, $f^2(x)\leq x^2$, thus $\int_0^1 f^2-f\leq \int _0^1(x^2+x) dx=\frac 56$, and this upper bound is attained for $f(x)=-x$, hence $\sup_{f\in A}\left[\int_0^1f^2-f\right] = \max_{f\in A}\left[\int_0^1f^2-f\right]=\frac 56$.
Note also that $\int f^2-f\geq -\int_0^1 f\geq -\int_0^1 x=-\frac 12$. Hence $\inf_{f\in A}\left[\int_0^1f^2-f\right]\geq -\frac 12$ and $$\max\left(\sup_{f\in A}\left[\int_0^1f^2-f\right], -\inf_{f\in A}\left[\int_0^1f^2-f\right] \right) = \sup_{f\in A}\left[\int_0^1f^2-f\right] = \max_{f\in A}\left[\int_0^1f^2-f\right]=\frac 56$$ thus $$\sup_{f\in A}\left|\int_0^1f^2-f \right|=\frac 56$$ and the upper bound is attained for $x\mapsto -x$.