Value of $I=\inf_{f\in S} \int_0^1 f(x)^2 \, \text{d}x$ I was asked the following question

Consider the set
$$S=\left\{f:[0,1]\to \mathbb R : f \text{ is continuous}, \int_0^1 f(x)\,\text{d}x=5, \int_0^1 xf(x) \, \text{d}x=3\right\}$$
Let
$$I=\inf_{f\in S} \int_0^1 f(x)^2 \,\text{d}x$$
Find the value of $I$.

I can understand that we need an inequality (or an equality) involving the terms $\int_0^1 f(x) \, \text{d}x=5$, $\int_0^1 xf(x)\,\text{d}x=3$ and $\int_0^1 f(x)^2 \,\text{d}x$. But I don't have any idea of where to start or how to proceed. I guess, first we need to find a relation between $\left(\int_0^1 f(x) \, \text{d}x\right)^2$ and $\int_0^1 f(x)^2 \,\text{d}x$, but still, it's not clear to me how to proceed.
Any help would be appreciated.
 A: Consider integral $$ \int_0^1 (ax+b)f(x)\,dx = 3a + 5b$$
Using Cauchy-Schwarz inequality on it, we get $$ (3a+5b)^2 \le \int_0^1(ax+b)^2\,dx \int_0^1f^2(x)\,dx = \left (\frac{a^2}{3} + ab + b^2 \right )\int_0^1f^2(x)\,dx $$
Rearranging (and letting $b \neq 0$) $$ \int_0^1 f^2(x)\,dx \ge \frac{27a^2 + 90ab + 75b^2}{a^2 + 3ab + 3b^2} = \frac{27(\frac{a}{b})^2 + 90(\frac{a}{b}) + 75}{(\frac{a}{b})^2 + 3(\frac{a}{b}) + 3} = \frac{27t^2 + 90t + 75}{t^2 + 3t + 3} $$
By taking derivative u can obtain that the maximum of the function on the right is at $t=3$ and yields the value of $28$.
Combining with @projectilemotion comment, function $f:[0,1] \to \mathbb R$ given by $f(x)=6x+2$ gives us $\int_0^1 f^2(x)\,dx = 28$, hence such infimum is $28$, too and is attained.
A: Here is an approach using linear algebra. Consider the inner product $\langle \cdot,\cdot \rangle:C([0,1])\times C([0,1])\to \mathbb{R}$ by
$$\langle f,g\rangle=\int_0^1 f(x)g(x)~dx.$$
Now consider the subspace $W:=\operatorname{span}\{1,x\}$ of $C([0,1])$. By the Gram-Schmidt process, one finds the orthonormal basis $\{e_1,e_2\}$ for $W$ with
$$e_1(x)=1,\quad e_2(x)=2\sqrt{3}(x-1/2).$$
The orthogonal projection $P_W$ onto $W$ is then given by
$$(P_W f)(x)=\sum_{i=1}^2 \langle f,e_i\rangle e_i(x)=6x+2,$$
where we have used that $\langle f,e_1\rangle=5$ and $\langle f,e_2\rangle=\sqrt{3}$ (note the integrals that $f\in S$ must satisfy). It is well-known for orthogonal projections that we have $\|P_W f\|\leq \|f\|$ for all $f\in C([0,1])$, hence it follows from the fact that $\|P_W f\|^2=\int_0^1 (6x+2)^2~dx=28$ that $\|f\|^2\geq 28$ for all $f\in S$. Hence we have that $I=28$, where the infimum is attained at $f(x)=6x+2$.
