# [Math] Finding the orthogonal projection of a function onto a subspace.

linear algebraorthogonality

Find the orthogonal projection of the function $f(x)=x$ onto the subspace of
$C([-1,1])$ spanned by $\sin\pi$x , $\sin2\pi$x, $\sin3\pi$x .

I was given this problem and I don't really know how to go about solving it. I understand orthogonal projection with vectors and can use Gram-Schmidt but I'm a bit confused how to even begin with this sort of problem. Any help would be much appreciated.

Note that the inner product in $V=C([-1,1])$ is defined as $$\langle f,g\rangle=\int_{-1}^1f(x)g(x)\ dx\tag{1}$$ Now you have three vectors in $V$, $$v_1=\sin(\pi x), v_2=\sin(2\pi x), v_3=\sin(3\pi x).$$ And of course $f(x)=x$ is another vector in $V$. Denote it as $v=f$. Do you feel more familiar with this setting now and know how to go on?
Moreover, you don't need Gram-Schmidt here since $\{v_1,v_2,v_3\}$ is already an orthonormal set.
Calculate $\langle v,v_i\rangle$ for $i=1,2,3$ using (1). Then the projection is given by $$a_1v_1+a_2v_2+a_3v_3$$ where $a_i=\langle v,v_i\rangle$.