Projection of a vector onto a subspace Let $V$ be the vector space of all continuous real-valued functions on $[-1,1]$. For all $f,g \in V$ define the inner product
$$\langle f,g \rangle =\int_{-1}^1 f(x)g(x)~\mathrm dx$$
Let $v_1(x)=1$, $v_2(x)=x$, and $v_3(x)=x+x^2$ be functions in $V$.
I want to find the projection of $v_3$ onto the subspace $S=\text{span}\left\{ v_1, v_2 \right\}$.
I believe the answer is $x$, but I am not fully convinced. I see that $v_3$ is the sum of a vector in $S$, namely $x$, and a vector not in $S$, namely $x^2$. However, $x^2 \notin S^\perp$ because for any $a_1+a_2x\in S$ we have
$$\langle a_1+a_2x, x^2 \rangle =a_1 \langle 1,x^2\rangle +a_2 \langle x,x^2\rangle=a_1 \int_{-1}^1 x^2~\mathrm dx + a_2 \int_{-1}^1 x^3~\mathrm dx,$$
which will not be equal to zero if $a_1 \neq 0$. 
Not sure what to do here...some help?
 A: We may compute the projection as
$$
\operatorname{proj}_S(v_3) = \frac{\langle v_1, v_3\rangle}{\langle v_1, v_1\rangle}v_1 + \frac{\langle v_2, v_3\rangle}{\langle v_2, v_2\rangle}v_2
$$
since $v_1$ and $v_2$ are orthogonal. If they were not orthogonal, we would first have to apply the Gram-Schmidt procedure to produce an orthogonal basis of $S$, as in Omnomnomnom's answer, in order to use this formula. Evaluating our desired expressions:
\begin{align}
\langle v_1, v_3\rangle &= \int_{-1}^1(x + x^2)\,dx = 2/3, \\
\langle v_2, v_3\rangle &= \int_{-1}^1(x^2 + x^3)\,dx = 2/3, \\
\langle v_1, v_1\rangle &= \int_{-1}^1 1\,dx = 2, \\
\langle v_2, v_2\rangle &= \int_{-1}^1 x^2\,dx = 2/3.
\end{align}
Hence, 
$$
\operatorname{proj}_S(v_3) = \tfrac{1}{3}v_1 + v_2 = 1/3 + x.
$$
A: First, use the Gram-Schmidt procedure to get an orthonormal basis $u_1,u_2$ for that space.  We have
$$
u_1(x) = \frac{v_1(x)}{\sqrt{\langle v_1,v_1\rangle}} = \frac 1{\sqrt{2}}\\
v_2^{\perp} = v_2 - \langle v_2,v_1 \rangle v_1 = v_2\\
u_2(x) = \frac{v_2^{\perp}(x)}{\sqrt{\langle v_2,v_2\rangle}} = \sqrt{\frac 32}
$$
Compute the projection as
$$
v_{3}^{||}(x) = \langle v_3,u_1\rangle u_1(x) + \langle v_3,u_2\rangle u_2(x) =\\ 
\frac{2}{3\sqrt{2}} \cdot \frac{1}{\sqrt{2}} + \sqrt{\frac 32}\cdot \frac{2}{3} \cdot \sqrt{\frac 32} x =\\
\frac 13 + x
$$
