Let $P_2 =\lbrace a_0 +a_1t+a_2t^2:a_0,a_1,a_2 \in R \rbrace$ be the set of polynomials of degree $2$ or less. The linear mapping $D:P_2\to P_2$ is such that $$D(p(t)) = \frac{d}{dt} (t \cdot p(t))$$for $p(t) \in P_2$.
a. Show that $B = \lbrace 1, \space 1+t, \space 1+ t + t^2 \rbrace$ is a basis for $P_2$
b. Find the transformation matrix representing $D$ with respect to the basis $B$.
This is a question from last year's final examination..I have already shown that $B$ is a basis for $P_2$, but I actually have no clue how to do the second part. I have compiled my answer based on what I have seen done in similar questions, but I am not sure if it makes any sense or if I am way off the mark? As a result, I am not really sure of the logic behind it either.
My attempt:
First we have to find $D(1), \space D(1+t), \space D(1+t+t^2)$ $$D(1) = \frac{d}{dt} t=1$$ $$D(1+t) =\frac{d}{dt}(t+t^2)=1+2t$$ $$D(1+t+t^2) =\frac{d}{dt} (t+t^2+t^3) = 1+2t+3t^2$$ Then we have to express in terms of the basis vectors of the range which is $\lbrace 1, \space 1+t, \space 1+ t + t^2 \rbrace$. So now :
$$D(1) = 1 \implies 1 + 0 \cdot (1+t) + 0 \cdot (1+t+t^2) \therefore (1,\space0,\space0)$$ $\space$ $$D(1+t) = 1+ 2t = a(1) + b(1+t) + c(1+t+t^2)$$
$$= 1+2t = (a + b + c) + (b + c)t + ct^2$$
$$a + b+ c =1, \space b+c = 2$$
$$c =0, \space b=2, \space a = -1$$ $$1+2t = -1(1) + 2(1+t) + 0(1+t+t^2) \implies -1 + 2(1+t)$$ $$\therefore (-1,\space2,\space0)$$ $\space$ $$D(1+t+t^2)=1+2t+3t^2 = a(1)+b(1+t)+c(1+t+t^2)$$ $$=1+2t+3t^2= (a + b + c) + (b + c)t + ct^2$$
$$a+b+c = 1, \space b+c =2$$
$$c=3, \space b=-1, \space a=-1$$ $$1+2t+3t^2 = -1(1)+(-1)(1+t)+3(1+t+t^2) \implies -1 -(1+t) + 3(1+t+t^2)$$ $$\therefore (-1,\space-1,\space3)$$ $\space$
And finally, the transformation matrix representing $D$ with respect to the basis $B$ would be the transpose of the each vector, which would give:
$$ \begin{pmatrix} 1 & -1 & -1 \\ 0 & 2 & -1 \\ 0 & 0 & 3 \\ \end{pmatrix} $$