Orthonormal $f−\sum_{k=1}^na_k\phi_k$ For this:
Given  an  Euclidean  space $R$,  let $\{φ_n\}_{n=1}^\infty$ be  an  orthonormal  basis  in $R$ and $f$ an arbitrary element of $R$. Prove that the element $f−\sum_{k=1}^na_k\phi_k$ is orthogonal to all linear combinations of the form $\sum_{k=1}^nb_k\phi_k$ if and only if $a_k= (f,\phi_k)$ $(k= 1,2,...,n)$
My proof is:
$\{\phi_n\}$ is an orthonormal basis in $R$, so $f=\sum_{k=1}^\infty c_k\phi_k$ for some scalars $\{c_k\}$. Therefore,
$$
f-\sum_{k=1}^n a_k\phi_k
=\sum_{k=1}^\infty c_k\phi_k - \sum_{k=1}^n a_k\phi_k.
$$
Thus,
\begin{align}
\left(f-\sum_{k=1}^n a_k\phi_k, \sum_{k=1}^n b_k\phi_k\right)
&=\left(\sum_{k=1}^\infty c_k\phi_k - \sum_{k=1}^n a_k\phi_k, \sum_{k=1}^n b_k\phi_k)\right)\\
&=\left(\sum_{k=n+1}^\infty c_k\phi_k + \sum_{k=1}^n (c_k-a_k)\phi_k, \sum_{k=1}^n b_k\phi_k\right)\\
&=\left(\sum_{k=n+1}^\infty c_k\phi_k , \sum_{k=1}^n b_k\phi_k\right)+\left( \sum_{k=1}^n (c_k-a_k)\phi_k, \sum_{k=1}^n b_k\phi_k\right)
\end{align}
Since $\{\phi_k\}$ is an orthonormal basis, the scalar product $$
\left(\sum_{k=n+1}^\infty c_k\phi_k , \sum_{k=1}^n b_k\phi_k\right)=0
$$
for any $b_k$ in $\sum_{k=1}^n b_k\phi_k$ since $\{\phi_k\}_{k=1}^n$ and $\{\phi_k\}_{k=n+1}^\infty$ do not share any common $\phi_k$.
$$
\left(f-\sum_{k=1}^n a_k\phi_k, \sum_{k=1}^n b_k\phi_k\right)=0+\left( \sum_{k=1}^n (c_k-a_k)\phi_k, \sum_{k=1}^n b_k\phi_k\right)
$$
But
$$\left( \sum_{k=1}^n (c_k-a_k)\phi_k, \sum_{k=1}^n b_k\phi_k\right)= \sum_{k=1}^n (c_k-a_k)b_k\phi_k=0
$$
for all linear combinations $\sum_{k=1}^n b_k\phi_k$ if and only if $c_k-a_k=0$ for all $k=1,\ldots,n$
$$
\Longleftrightarrow a_k=c_k=(f,\phi_k)~\mbox{ for all }~k=1,\ldots,n
$$
In conclusion:
$$
\left(f-\sum_{k=1}^n a_k\phi_k, \sum_{k=1}^n b_k\phi_k\right)
=
0\Longleftrightarrow a_k=c_k=(f,\phi_k)~\mbox{ for all }~k=1,\ldots,n\,.
$$
Am I missing something? The If and only If statement seems to be satisfied.
 A: What if we write $\sum_{k=1}^n b_k\phi_k$ as $\sum_{j=1}^n b_j\phi_j$? Then your proof falls down. Here is a more elementary way:
$$
\begin{align}
& f−\sum_{k=1}^na_k\phi_k \textrm{ is orthogonal to any linear combination of } \phi_1,\dots,\phi_n \\
& \iff f−\sum_{k=1}^na_k\phi_k \textrm{ is orthogonal to } \phi_1,\dots,\phi_n \\
& \iff \textrm{for $i=1,\dots,n$ we have } 0 = \Big( f−\sum_{k=1}^na_k\phi_k, \phi_i \Big) = (f,\phi_i) - \underbrace{\sum_{k=1}^na_k(\phi_k,\phi_i)}_{a_i}.
\end{align}
$$
A: In your proof, the step

...But
$$\left( \sum_{k=1}^n (c_k-a_k)\phi_k, \sum_{k=1}^n b_k\phi_k\right)= \sum_{k=1}^n (c_k-a_k)b_k\phi_k=0
$$
for all linear combinations $\sum_{k=1}^n b_k\phi_k$ if and only if $c_k-a_k=0$ for all $k=1,\ldots,n$
$$
\Longleftrightarrow a_k=c_k=(f,\phi_k)~\mbox{ for all }~k=1,\ldots,n
$$

is problematic.  First of all, let's be more careful and use different names for the indices for the different sums, so that we can pull them out of the inner product without worrying, i.e.,
\begin{align}
\left( \sum_{k=1}^n (c_k-a_k)\phi_k, \sum_{j=1}^n b_j\phi_j\right)
&=
\sum_{j,k=1}^n(c_k-a_k)b_j(\phi_k,\phi_j)
=\sum_{j,k=1}^n(c_k-a_k)b_j\delta_{jk}\\
&=\sum_{k=1}^n(c_k-a_k)b_k.
\end{align}
Now, at this point:

*

*The sum is obviously zero for all choices of $b_k$ if $a_k=c_k$, obviously.


*Arguing in the other direction: if this sum is zero for all choices of $b_k$, then it's zero for the choice $b_k=\delta_{km}$, i.e., only one of the $b_k$'s is zero--the $m$'th one. This implies that $c_m-a_m=0$ for all $1\leq m\leq n$.
This completes your otherwise correct proof.  Note that the argument I've just made is essentially the same as the one in azif00's answer, just written in terms of the components of the vectors in the basis, as in your proof.
