Why do I get this matrix the wrong way round? The question is: The set B = {${1+t^2, t+t^2, 1+2t+t^2}$} is a basis for P2. Find the coordinate vector of $p(t)=1+4t+7t^2$ relatvive to B.
I made a matrix:
  \begin{bmatrix}
    1 & 0 & 1 & 1\\ 0 & 1 & 2 & 4\\
    0 & 1 & 0 & 6
  \end{bmatrix}
When I row reduce it I get:
\begin{bmatrix}
    1 & 0 & 0 & -1\\ 0 & 1 & 0 & 6\\
    0 & 0 & 1 & 2
  \end{bmatrix}
But the solutions (and MATLAB) say it's:
\begin{bmatrix}
    1 & 0 & 0 & 2\\ 0 & 1 & 0 & 6\\
    0 & 0 & 1 & -1
  \end{bmatrix}
I've tried it many times and I still end up with the same matrix. Does anyone know what I've done wrong?
Thanks
 A: Here is one sequence of steps to row reduce the matrix.
\begin{bmatrix}
    1 & 0 & 1 & 1\\ 0 & 1 & 2 & 4\\
    0 & 1 & 0 & 6
  \end{bmatrix}
Subtract the second row from the third:
\begin{bmatrix}
    1 & 0 & 1 & 1\\ 0 & 1 & 2 & 4\\
    0 & 0 & -2 & 2
  \end{bmatrix}
Add the third to the second:
\begin{bmatrix}
    1 & 0 & 1 & 1\\ 0 & 1 & 0 & 6\\
    0 & 0 & -2 & 2
  \end{bmatrix}
Divide the third by $2$:
\begin{bmatrix}
    1 & 0 & 1 & 1\\ 0 & 1 & 0 & 6\\
    0 & 0 & -1 & 1
  \end{bmatrix}
Add the third to the first:
\begin{bmatrix}
    1 & 0 & 0 & 2 \\ 0 & 1 & 0 & 6\\
    0 & 0 & -1 & 1
  \end{bmatrix}
Multiply the third by $-1$:
\begin{bmatrix}
    1 & 0 & 0 & 2 \\ 0 & 1 & 0 & 6\\
    0 & 0 & 1 & -1
  \end{bmatrix}
A: Note that your matrix is not correct: you want to solve
$$\lambda_1(1 + t^2) + \lambda_2(t+t^2) + \lambda_3(1 + 2t + t^2) = 1 + 4t + 7t^2.$$
Hence if we compare the coefficients of the left hand side and the right hand side, we find that we want to solve the following system for $\lambda_1, \lambda_2, \lambda_3$: 
\begin{equation}
\begin{cases}
\lambda_1 + \lambda_3 = 1\\
\lambda_2 + 2\lambda_3 = 4\\
\lambda_1 + \lambda_2 + \lambda_3 = 7
\end{cases}.
\end{equation}
This results in the following (augmented) matrix:
\begin{equation}
\begin{pmatrix}
1 & 0 & 1 & 1\\
0 & 1 & 2 & 4\\
1 & 1 & 1 & 7
\end{pmatrix}.
\end{equation}
Forming this matrix into echelonform gives
$$\begin{pmatrix}
1 & 0 & 1 & 1\\
0 & 1 & 2 & 4\\
0 & 0 & 1 & -1
\end{pmatrix}$$
and using back substitution, we find the solution $(\lambda_1, \lambda_2, \lambda_3) = ( 2, 6, -1)$.
$\textbf{EDIT:}$ In order to find the Echelon form, I first replaced row 3 by (row 3 - row 1) to introduce a zero in the first column, third row. Then I replaced row 3 by (row 3 - row 2) to get the zero in the second column, third row. Back substitution is just filling in the values and working from the bottom up.
So you have probably made a computational error in your row reduction.
