TITLE: Integral of a square compared to the square of an integral
QUESTION [6 upvotes]: What can be said about a complex valued, continuous function $f$, defined on $[0,1]$, such that:
$$
\int_0^1{|f|^2}=\left|\int_0^1{f}\right|^2 
$$
I encountered this form as part of an exercise. Obviously, the above holds for any constant $f$, and it seems intuitive that the converse also holds (i.e. that if the above equality is true, then $f$ is constant), but I could not prove it.
Any help will be appreciated.

REPLY [10 votes]: This is a case of equality in the   Cauchy-Schwarz Inequality
$$\left|\int_{0}^1 f\overline g\right|^2\leq \int_0^1 |f|^2\int _0^1|g|^2 $$
where $g=1$ is a constant function. And the equality holds if and only if $f$ and $g$ are dependent,i,e $f$ is a scalar multiple of $g$.

Note that when we change the bounds to $a,b$, the equality in question is not true for constants functions $f$