The following problem is from Andreescu's "Problems in Real Analysis: Advanced Calculus on the real axis". More specifically it's problem $10.6.11$:
Let $f:[0,1]\rightarrow\mathbb{R}$ be a function of class $C^1$ such that $f(0)=f(1)=0$. Prove that $$\left(\int_0^1 f(x)dx\right)^2\leq\frac{1}{12}\int_0^1\left(f'(x)\right)^2dx$$ and find for what functions the equality holds.
I have only been able to prove a weaker bound as follows: $$\left(\int_0^1 f(x)dx\right)^2 \stackrel{CS}{\le} \int_0^1 \left(f(x)\right)^2dx = \int_0^1 \left(\int_0^xf'(t)dt\right)^2dx\stackrel{CS}{\le}\int_0^1x\left(\int_0^x\left(f'(t)\right)^2dt\right)dx$$
Already here, having used the Cauchy-Schwarz inequality twice, the only functions satisfying both inequalities as equalities are constant ones ($f$ must be constant and so must $f'$). My attempt continues as follows
$$\int_0^1x\left(\int_0^x\left(f'(t)\right)^2dt\right)dx=\int_0^1\left(\frac{x^2}{2}\right)'\left(\int_0^x\left(f'(t)\right)^2dt\right)dx$$
Integrating by parts this is equal to
$$\left[\frac{x^2}{2}\left(\int_0^x\left(f'(t)\right)^2dt\right)\right]_0^1-\int_0^1\frac{x^2}{2}\left(f'(x)\right)^2dx$$
Which is
$$\frac{1}{2}\int_0^1\left(f'(x)\right)^2dx-\frac{1}{2}\int_0^1\left(xf'(x)\right)^2dx\stackrel{CS}{\le}\frac{1}{2}\int_0^1\left(f'(x)\right)^2dx-\frac{1}{2}\left(\int_0^1xf'(x)dx\right)^2$$
But, using integration by parts once again, this is just
$$\frac{1}{2}\int_0^1\left(f'(x)\right)^2dx-\frac{1}{2}\left(\int_0^1f(x)dx\right)^2$$
And thus using the original relation we have shown that
$$\left(\int_0^1 f(x)dx\right)^2\leq\frac{1}{3}\int_0^1\left(f'(x)\right)^2dx$$
I am wondering whether there is a point in my solution where I can improve one of the bounds to prove the desired result or I have to look for a completely different approach. Any hints and/or complete solutions are very welcome.