Find $\min\int_0^\pi {f^2(x)dx}$, assume $\int_0^\pi{f(x)\sin xdx} = \int_0^\pi{f(x)\cos xdx} = 1.$ $f(x)$ is continuous on $[0,\pi]$ and $\int_0^\pi{f(x)\sin xdx} = \int_0^\pi{f(x)\cos xdx} = 1.$
Find $\min\int_0^\pi {f^2(x)dx}.$
I try to solve this problem by this:
$$\begin{array}{l}
{\left( {\int\limits_0^\pi  {f(x)\sin xdx} } \right)^2} \le \left( {\int\limits_0^\pi  {{f^2}(x){{\sin }^2}xdx} } \right)\left( {\int\limits_0^\pi  {dx} } \right) \le \pi \int\limits_0^\pi  {{f^2}(x){{\sin }^2}xdx} \\
{\left( {\int\limits_0^\pi  {f(x)\cos xdx} } \right)^2} \le \pi \int\limits_0^\pi  {{f^2}(x){{\cos }^2}xdx} \\
 \Rightarrow \pi \int\limits_0^\pi  {{f^2}(x)\left( {{{\sin }^2}x + {{\cos }^2}x} \right)dx}  \ge 1 + 1 = 2
\end{array}$$
The thing is I can't find $f(x)$ to let the equation happens. Any help? Thank you in advance.
 A: Let us consider the Fourier series of $f$
\begin{align}
f(x) = \frac{1}{2}a_0+\sum^\infty_{n=1} a_n \cos nx+ \sum^\infty_{n=1} b_n \sin nx
\end{align}
then that means
\begin{align}
\int^\pi_0 f^2(x)\ dx= \frac{1}{4}a_0^2+\frac{\pi}{2}\sum^\infty_{n=1}(a_n^2+b_n^2).
\end{align}
Since
\begin{align}
\int^\pi_0 f(x) \cos x\ dx = 1
\end{align}
then this means $a_1= 2/\pi$ and likewise $b_1 = 2/\pi$. It follows
\begin{align}
\int^\pi_0 f^2(x)\ dx \geq \frac{4}{\pi}= \frac{\pi}{2}(a_1^2+b_1^2).
\end{align}
A: Define
$$
 g(x) = f(x) - \frac 2\pi \sin x - \frac 2\pi \cos x \, .
$$
Then
$$
 \int_0^\pi g(x) \cos x \, dx= \int_0^\pi f(x) \cos x \, dx
 - \frac 2\pi \int_0^\pi \sin x \cos x \, dx
 - \frac 2\pi \int_0^\pi \cos^2 x \, dx \\
 = 1 - 0 - 1 = 0
$$
and similarly, 
$$
 \int_0^\pi g(x) \sin x \, dx= 0 \, .
$$
Therefore
$$
 \int_0^\pi f^2(x) = \int_0^\pi \left( g(x) + \frac 2\pi \sin x + \frac 2\pi \cos x\right)^2 \, dx \\
 =  \int_0^\pi g^2(x) \, dx + \frac{4}{\pi^2} \int_0^\pi \sin^2(x) \, dx
+ \frac{4}{\pi^2} \int_0^\pi \cos^2(x) \, dx
$$
because all integrals with the "mixed terms" from expanding the square
vanish.
It follows that
$$
\int_0^\pi f^2(x) \ge \frac{4}{\pi^2} \int_0^\pi \sin^2(x) \, dx
+ \frac{4}{\pi^2} \int_0^\pi \cos^2(x) \, dx
 = \frac 4 \pi \, .
$$
Equality holds if $g(x) = 0$, i.e. for the function
$$
 f(x) =  \frac 2\pi \sin x + \frac 2\pi \cos x \, .
$$
(This is essentially the same proof as given by Jacky Chong, but
  without using the theory of Fourier series.)

Another way to look at the problem is to consider the set of all
real-valued continuous functions on $[0, \pi]$ as 
inner product space
with the scalar product 
$$
 \langle g, h \rangle = \int_0^\pi g(x)h(x) \, dx \, .
$$
What we did is to define $g$ as the orthogonal projection of
$f$ on the subspace spanned by $\{ \sin, \cos \}$:
$$
g = f - \frac{\langle f, \sin \rangle}{\langle \sin, \sin \rangle} \sin
 - \frac{\langle f, \cos \rangle}{\langle \cos, \cos \rangle} \cos
 = f - \frac 2 \pi \sin - \frac 2 \pi cos
$$
and concluded that
$$
 \| f \|^2 = \langle f, f \rangle = \langle g, g \rangle
+ \frac{4}{\pi^2} \langle \sin, \sin \rangle + 
 \frac{4}{\pi^2} \langle \cos, \cos \rangle
 = \| g \|^2 + \frac 4 \pi \, .
$$
