Basis for a Subspace of Polynomials of Degree 5
$p(1) = p(-1) = 0$ is equivalent to $p(x)$ being divisible by $x^2-1$. So we can start by writing out a couple of simple multiples of $x^2-1$: $$ x^2-1, x(x^2-1), x^2(x^2-1), x^3(x^2-1) $$ These are linearly independent: write $0$ as a linear combination of the above polynomials. Only one of the polynomials has a degree 5 term, so its coefficient must be $0$. Once we know that, there is only one of the polynomials with a degree 4 term, so its coefficient must be $0$, and so on.
Also, together they can build any polynomial which is divisible by $x^2-1$ as a linear combination: if $p(x) = q(x)(x^2-1)$, then express $q(x)$ as a linear combination of $1, x, x^2$ and $x^3$ ($q(x)$ can't have degree higher than $3$, cause then $p(x)$ would have degree more than $5$), and the same coefficients will give you $p(x)$ as a linear combination of the polynomials above.
The general polynomial of degree $5$ is
$$p(x)=ax^5+bx_4+cx_3+dx^2+ex+f$$
and from the condition $p(1)=p(-1)=0$ we obtain
$a+b+c+d+e+f=0$
$-a+b-c+d-e+f=0$
from which, by adding and subtracting the two equations, we obtain
$2b+2d+2f=0 \implies f=-b-d$
$2a+2c+2e=0 \implies e=-a-c$
and finally
$$p(x)=ax^5+bx_4+cx_3+dx^2+(-a-c)x+(-b-d)\\=a(x^5-x)+b(x^4-1)+c(x^3-x)+d(x^2-1)$$
therefore a basis is given by:
$$\{x^5-x,x^4-1,x^3-x,x^2-1\}$$
Your answer is correct and span $W$.
One way to see it is the following:
- It is linearly independent as the degree are distincts.
- Consider: \begin{align} \phi:&P_5(\mathbb{R}) \to \mathbb{R}^2\\ &p \mapsto (p(-1),p(1)) \end{align} then $W=\ker(\phi)$. But as $\phi((x+1)/2)=(1,0)$ and $\phi((x-1)/2)=(0,1)$ you have $\dim(\phi(P_5(\mathbb{R})))=2$ so: $$\dim(W)=\dim(\ker(\phi))=\dim(P_5(\mathbb{R}))-\dim(\phi(P_5(\mathbb{R}))=6-2=4$$ and $4$ linearly independent vectors of a subspace of dimension $4$ is indeed a basis.