Explanation on derivation of this equation? I'm extremely stuck on how my book was able to derive this equation. Basically, it says:

Let $V = W = P_2(\mathbb{R})$. A basis for V is $1, 1+x, 1+x+x^2$. Define the linear transformation $T$ such that $T(1) = x$, $T(1+x) = x^2$ and $T(1+x+x^2) = 1$. If we express some $p(x)$ in terms of the basis we have:

$p(x) = (a_0 - a_1)1 + (a_1 - a_2)(1+x) + a_2(1+x+x^2)$


And it doesn't provide much of an explanation on how it was able to express this in terms of the basis and I've been pondering how for the past hour. Can someone please enlighten me?
Given $p(x) = a_0 + a_1 x + a_2 x^2$, need to find $\alpha_1, \alpha_2, \alpha_3$, such that
$$p(x) = \alpha_1 * (1) + \alpha_2 (1 + x) + \alpha_3 (1 + x +x^2) = a_0 + a_1 x + a_2 x^2$$
Expand LHS, 
$$(\alpha_1 + \alpha_2 + \alpha_3) + (\alpha+2 + \alpha_3) x + \alpha_3 x^2 = a_0 + a_1 x + a_2 x^2 $$

We have
$$\alpha_3  = a_2$$,
$$\alpha_2 + \alpha_3 = a_1$$,
$$\alpha_1 + \alpha_2 + \alpha_3 = a_0$$
Solve $\alpha$'s, get the answer.
The RHS can be written as a general quadratic by simplifying,$$p(x) =a_0+a_1x+a_2x^2$$

Since we already know that $\{1,1+x,1+x+x^2\}$ for a basis we know that we can write any polynomial of degree $2$ in terms of the elements of the above set.