Inequality of integrals $\int_0^1(f(x))^2 dx \geq 4$ if $\int_0^1xf(x) dx=\int_0^1f(x) dx = 1$

Of course once the inequality condition is obtained (or guessed by trying out a general linear polynomial), Cauchy-Schwarz is a breeze:

$$\int_0^1 f^2 dx \ge \frac{\left(\int_0^1 (3xf-f)dx\right)^2}{\int_0^1(3x-1)^2 dx } = \frac{4}{1}=4$$

Equality is when $f(x)$ is proportional to $3x-1$.

In general we can have $$\int_0^1 f^2 dx \ge \frac{\left(\int_0^1 (axf+bf)dx\right)^2}{\int_0^1(ax+b)^2 dx } = \frac{(a+b)^2}{a^2/3+ab+b^2}$$ where the maximum is when $(a, b)$ is proportional to $(3, -1)$, so $4$ is indeed the best possible.


Write your function in terms of the shifted Legendre polynomials $\tilde{L}_n(x)=L_n(2x-1)$, that are an orthogonal base of $L^2((0,1))$ with respect to the usual inner product. Assuming: $$ f(x) = \sum_{n=0}^{+\infty} a_n\,\tilde{L}_n(x), $$ the constraints give: $$ a_0 = 1,\qquad \frac{a_0}{2}+\frac{a_1}{6} = 1, $$ hence $a_0=1$ and $a_1=3$. This implies:

$$\int_{0}^{1}f(x)^2 dx = a_0^2+\sum_{n=1}^{+\infty}\frac{a_n^2}{2n+1}\geq 1+\frac{9}{3}=4.$$

Moreover, you have that equality holds only for $f(x)=6x-2$.


We have for each $a,b$: $$ \int_0^1 \Big(f(x)-ax-b\Big)^2dx \geq 0$$ So we have \begin{eqnarray*} \int_0^1 f(x)^2 dx &\geq &2\int _0^1f(x)(ax+b)dx -\int _0^1 (ax+b)^2dx \\ &=&2(a+b) -{(a+b)^3-b^3\over 3a}\\ &=&2(a+b) -{a^2+3ab+3b^2\over 3} =:E \end{eqnarray*} This inequality is valid for all $a,b$, so even when $E$ achieves maximum: \begin{eqnarray*} E &=&\underbrace{-b^2 +b(2-a) - {(2-a)^2\over 4}} + \underbrace{{(2-a)^2\over 4} -{a^2\over 3}}\\ &=&-\Big(b - {2-a\over 2}\Big)^2+{-a^2-12a+12\over 12}\\ &\leq & {-a^2-12a+12\over 12} \\ &=& {-(a-6)^2+48\over 12}\\ &\leq & 4 \end{eqnarray*} Equality is achieved at $a=6$ and $b={2-a\over 2}= -2$, that is when $f(x)=6x-2$.