# Linear algebra: projection

Consider $P_2$ together with the inner product $(p(x), q(x)) = p(0)q(0) + p(1)q(1) + p(2)q(2)$. Find the projection of $p(x)=x$ onto the subspace $W=\operatorname{span}\{-x+1,x^{2}+2\}$.

How do you solve this question? I don't get what it means to find the projection of $p(x)=x$ onto $W$. I'm only used to finding the projection of a vector onto $W$.

I did, however, find the orthogonal basis for the subspace being $\{-x+1, x^{2}-2x+4\}$. But I don't know how to apply this to the projection equation.

• If you have an orthonormal basis $\beta=\{v_1,\ldots,v_k\}$ for a subspace, then given a vector $u$, the projection onto the subspace of $u$ is $\langle u,v_1\rangle v_1 + \cdots + \langle u,v_k\rangle v_k$. If you have an orthogonal basis, then you can turn it into an orthonormal basis by dividing each vector by its norm. – Arturo Magidin Jun 24 '12 at 22:14
• P.S. "I'm only used to finding the projection of a vector onto $W$". $p(x)$ is a vector of the vector space $P_2$. – Arturo Magidin Jun 24 '12 at 22:14
• I geuss $W$ is a subspace of $P_2$ with orthogonal basis ${−x+1,x^{2}−2x+4}$ – Erik Jun 24 '12 at 22:17
• @Erik: Before it was stated what $W$ was (the problem was just edited), the alleged orthogonal basis appeared ex nihilo; no way to verify if it was correct or not. – Arturo Magidin Jun 24 '12 at 22:18

Suppose $\mathbf{V}$ is an inner product vector space, and $\mathbf{W}$ is a subspace. If $\beta=\{\mathbf{w}_1,\ldots,\mathbf{w}_k\}$ is an orthonormal basis for $\mathbf{W}$, then the orthogonal projection onto $\mathbf{W}$ can be computed using $\beta$: given a vector $\mathbf{v}$, the orthogonal projection onto $\mathbf{W}$ is $$\pi_{\mathbf{W}}(\mathbf{v}) = \langle \mathbf{v},\mathbf{w}_1\rangle \mathbf{w}_1+\cdots + \langle \mathbf{v},\mathbf{w}_k\rangle \mathbf{w}_k.$$

If you only have an orthogonal basis, then you need to divide each factor by the square of the norm of the basis vectors. That is, if you have an orthogonal basis $\gamma = \{\mathbf{z}_1,\ldots,\mathbf{z}_k\}$, then the projection is given by: $$\pi_{\mathbf{W}}(\mathbf{v}) = \frac{\langle\mathbf{v},\mathbf{z}_1\rangle}{\langle \mathbf{z}_1,\mathbf{z}_1\rangle}\mathbf{z}_1 + \cdots + \frac{\langle\mathbf{v},\mathbf{z}_k\rangle}{\langle\mathbf{z}_k,\mathbf{z}_k\rangle}\mathbf{z}_k.$$

Here, you have a subspace for which you say you already have an orthogonal basis. And you have your vector: $\mathbf{v} = x$. So all you have to do is use the usual formula with these vectors and this inner product. For example, with $\mathbf{v}=x$ and $\mathbf{z}_1 = -x + 1$, we have: $$\langle x,-x+1\rangle = (0)(-0+1) + (1)(-1+1) + (2)(-2+1) = 0+0-2 = -2.$$

Etc.

• Btw, for $z_2$=$x^{2}-2x+4$, would it be $\frac{11}{41}$($x^{2}$-2x+4}? – Ashley Jun 24 '12 at 22:40
• What would "it" be? There are so many things to compute, I don't know which one you mean. The projection of $x^2-2x+4$? The normalization of $x^2-2x+4$ onto $\mathbf{W}$? The inner product of $\mathbf{v}$ with $\mathbf{z}_1$? The projection of $\mathbf{v}$ onto $\mathrm{span}(\mathbf{z}_1)$? Something else? Impossible to tell. – Arturo Magidin Jun 24 '12 at 22:44
• Sorry for being so ambiguous. I meant the projection of $x^{2}-2x+4$ on W. – Ashley Jun 24 '12 at 22:46
• @Ashely: Since $x^2-2x+4$ is in $\mathbf{W}$, it's orthogonal projection on $\mathbf{W}$ is itself. So if you really meant that, then I have no idea what you calculated or where $\frac{11}{41}$ came from. – Arturo Magidin Jun 24 '12 at 22:47
• I guess I mixed it up. The inner product of v with $z_2$=$x^{2}-2x+4$ would be what I was to say. – Ashley Jun 24 '12 at 22:51