Polynomial Orthogonal Complement 
Let $V = \mathbb{P^4}$ denote the space of quartic polynomials, with
  the $L^2$ inner product $$\langle p,q \rangle = \int^1_{-1}
 p(x)q(x)dx.$$ Let $W = \mathbb{P^2}$ be the subspace of quadratic
  polynomials. Find a basis for and the dimension of $W^{\perp}$.

The answer is $$t^3 - \frac{3}{5}t, t^4 - \frac{6}{7}t^2 + \frac{3}{35};\,\, \dim (W^{\perp}) =2$$
How did they get that?
 A: Well, one way would be to use Gram-Schmidt to produce an orthogonal basis,
starting with the basis $1$, $t$, $t^2$, $t^3$, $t^4$. The result will be five polynomials $p_r(x)$ for $r=0,\ldots,4$ where $p_r$ has degree $r$. So $p_0$, $p_1$ and $p_2$ will span the space of quadratic polynomials and $p_3$ and $p_4$ will span a 2-dimensional space orthogonal to the quadratics. Since we know that the dimension of $W^\perp$ is two (because $\mathrm{dim}(W)+\mathrm{dim}(W^\perp)=5$), we see that $p_3$ and $p_4$ are a basis for $W^\perp$.
A: Well, for a finite dimensional vector space we have $\dim W + \dim W^\perp = \dim V$ so that covers the dimension part. For the basis of the orthogonal complement, we have
$$\int_{-1}^1 ax^4 + bx^3 + cx^2 + dx + e\ dx = 0$$
$$\int_{-1}^1 x(ax^4 + bx^3 + cx^2 + dx + e)\ dx = 0$$
$$\int_{-1}^1x^2(ax^4 + bx^3 + cx^2 + dx + e)\ dx = 0$$
Because the standard basis of $\mathbb{P}^2$ must satisfy the orthogonality conditions. Therefore we get
$$\frac{a}{5} + \frac{c}{3}  + e = 0$$
$$\frac{b}{5} + \frac{d}{3} = 0$$
$$\frac{a}{7} + \frac{c}{5} + \frac{e}{3} = 0$$
Solving this system yields 
$$a = \frac{35}{3}e,\ \ b=-\frac{5}{3}d,\ \  c=-10e$$
with two parameters to vary. Your solutions follows by taking $(a=0,\ b=1)$ and $(a=1,\ b=0)$ respectively.
A: Let
$$p(x):=ax^4+bx^3+cx^2+dx+e\in W^\perp$$
Since $W:=\operatorname{Span}\{1,x,x^2\}\,$ , we get:
$$(1)\;\;\;\;\;\;0=\langle\,p\,,\,1\,\rangle=\int_{-1}^1p(x)dx=\frac{2}{5}a+\frac{2}{3}c+2e$$
$$(2)\;\;\;\;\;\;\;\;\;\;\;0=\langle\,p\,,\,x\,\rangle=\int_{-1}^1xp(x)dx=\frac{2}{5}b+\frac{2}{3}d$$
$$(3)\;\;\;\;\;\;\;\;0=\langle\,p\,,\,x^2\,\rangle=\int_{-1}^1x^2p(x)dx=\frac{2}{7}a+\frac{2}{5}c+\frac{2}{3}e$$
The above relies on the easy results that the integral on a symmetric (above zero) interval of an even function is twice the value of its primitive on either of the two limits, whereas the same integral of an odd function is zero.
Now solve the above linear system.
A: Let $v_k(x) = x^k$, $k=0,...,4$. Then $v_k$ is a basis for $\mathbb{P}^4$. (To see this note that any quartic can be written in terms of $v_k$, and if $\sum \alpha_k v_k = 0$, then by differentiating and evaluating at $x=0$ we can see that $\alpha_k = 0$, hence they are linearly independent.)
By the same token, $v_k$, $k=0,1,2$ is a basis for $\mathbb{P}^2$. It follows that $\dim \mathbb{P}^2 = 3$, and since $\mathbb{P}^4 = \mathbb{P}^2 \oplus (\mathbb{P}^2)^\bot$, we see that $\dim (\mathbb{P}^2)^\bot = 2$.
We can find a basis for $(\mathbb{P}^2)^\bot$ by projecting the $v_k$ onto $(\mathbb{P}^2)^\bot$. Clearly $v_k$, $k=0,1,2$ will project to zero. So the only remaining basis elements that need to be projected are $v_3,v_4$.
Note in passing that $\langle v_j, v_k \rangle = \frac{1}{j+k+1}(1-(-1)^{j+k+1})$.
To compute the projection of $x$ onto $(\mathbb{P}^2)^\bot$, we need to determine $\alpha \in \mathbb{R}^3$ such that $\langle x-\sum_{k=0}^2 \alpha_k v_k, v_j \rangle = 0$ for $j=0,1,2$. This is just the linear system $\langle x, v_j \rangle  = \langle \sum_{k=0}^2 \alpha_k v_k, v_j \rangle$, or
$$
\begin{bmatrix}
\langle v_0,  v_0 \rangle & \langle v_1,  v_0 \rangle & \langle v_2, v_0  \rangle \\
\langle v_0,  v_1 \rangle & \langle v_1,  v_1 \rangle & \langle v_2, v_1  \rangle \\
\langle v_0,  v_2 \rangle & \langle v_1,  v_2 \rangle & \langle v_2, v_2  \rangle
\end{bmatrix}
\alpha = 
\begin{bmatrix}
\langle x,  v_0 \rangle \\
\langle x,  v_1 \rangle \\
\langle x,  v_2 \rangle 
\end{bmatrix}
$$
Grinding through the computations gives $\alpha = \frac{1}{5} (0,3,0)^T$ when $x=v_3$ and $\alpha = \frac{1}{35} (-3, 0, 30)^T$ when $x=v_4$.
Hence a basis for $(\mathbb{P}^2)^\bot$ is $x \mapsto x^3-\frac{3}{5}x$, $x \mapsto x^4+\frac{3}{35}-\frac{6}{7}x^2$.
