Find a basis and coordinates for a second degree polynomial

Find a basis $$B$$ for $$P_2$$

$$[p]_B = \begin{bmatrix}p(0)\\p(1)\\p(2)\end{bmatrix}$$

and its coordinates to a second degree polynomial

The solutions says:

$$p(x) = p(0)e_1(x) + p(1)e_2(x) + p(2)e_3(x)$$, where

$$e_1(x): e_1(0) = 1,\ e_1(1) = 0,\ e_1(2) = 0$$

$$e_2(x): e_2(0) = 0,\ e_2(1) = 1,\ e_2(2) = 0$$

$$e_3(x): e_3(0) = 0,\ e_3(1) = 0,\ e_3(2) = 1.$$

But I don't understand the solution. Can someone please explain?

• What this basis is doing is interpolating each polynomial $p$. Therefore, it should consists of the Lagrange polynomials for the points $0,1,2$. That would be $b_1(x)=\frac{(x-1)(x-2)}{(0-1)(0-2)}, b_2(x)=\frac{x(x-2)}{(1-0)(1-2)},$ and $b_2(x)=\frac{x(x-1)}{(2-0)(2-1)}$. – logarithm May 24 at 19:19