Function minimum and Fourier series. I'm preparing for my calculus exam.And I have one examle in my textbook that put me in a deadlock.

Suppose $f(x)$- piecewise continuous function on $[a,b]\in
> \mathbb{R}$, $\{\phi_k(x)\}$ is orthogonal system of functions in
  space of piecewise continuous functions. Suppose that $f_k$-Fourier
  coefficients of function $f(x)$. What is the minimum value of function
  $$F(C_1,C_2,...,C_n)=\int_a^b\left(f(x)-\sum_{k=1}^nC_k\phi_k\right)^2dx.$$ And for what values ​​of the argument, it is achieved?

I know a theorem about the extremal property of the Fourier series.

If Fourier series $\sum_kx^ke_k$ of vector $x\in X$ converges to vector $x_l\in X$, then $\forall y=\sum_{k=1}^\infty\alpha_ke_k$ we have
  $$||x-x_l||\leq||x-y||,$$ with equality when $y=x_l$

So, as I understand it, the minimum is achieved when $C_k$ equal to Fourier
coefficients of function $f(x)$, but I don't understand what is the minimum value of function $F$.
 A: Well, there are various ways of doing it. First, I will assume that the $\phi_k$ are orthonormal, not just orthogonal. Then just evaluate the integral and minimize directly.
Let me use the symbol $\hat{f}$ to denote the Fourier coefficients of $f$.
\begin{eqnarray}
F(C) &=& \|f-\sum_{k=1}^n C_k \phi_k \|^2 \\
&=& \|f\|^2-2\sum_{k=1}^n C_k \langle f, \phi_k \rangle + \sum_{k=1}^n C_k^2 \\
& = & \|f\|^2-2\sum_{k=1}^n C_k \hat{f}_k + \sum_{k=1}^n C_k^2
\end{eqnarray}
Now note that $F(\hat{f}) = \|f\|^2-\sum_{k=1}^n \hat{f}_k^2$, so we can write $F(C) = F(\hat{f})+ \sum_{k=1}^n |C_k-\hat{f}_k|^2$ (or $F(C) = F(\hat{f})+ \|C-\hat{f}\|^2$, using the $2$-norm on $\mathbb{R}^n$), from which the minimum value and the minimizing coefficients can be easily computed.
A: The minimum value is achieved when
$$ C_k = \frac{\int_a^b dx \: f(x) \phi_k{(x)}}{\int_a^b dx \: \phi_k{(x)}^2} $$
assuming that you are dealing with a real orthogonal basis set of functions $\phi_k$.  The denominator is 1 when the set is orthonormal.
