Calculate the Nullspace of a Matrix

We want to find the nullspace of AA

A=[111112344321] A = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & 2 & 3 & 4 \\ 4 & 3 & 2 & 1 \end{bmatrix}

AA and UU have the same nullspace. Elimination brings us to UU

A  ⟹  [111101230−1−2−3]  ⟹  [111101230000]=U A \implies \begin{bmatrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 2 & 3 \\ 0 & -1 & -2 & -3 \end{bmatrix} \implies \begin{bmatrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 2 & 3 \\ 0 & 0 & 0 & 0 \end{bmatrix} =U

We identify our pivot columns and our free columns. The pivot columns, x1x_1, and x2x_2 contain our pivots. The other columns, x3x_3 and x4x_4, are free. Now we have two choices: back substitution, and solving by row reduced echelon form.

Back Substitution

For each free column, xnx_n:

  1. Set that column to 1
  2. Set all the other free columns to 0
  3. Solve all equations for 0 with back substitution

The upper triangular matrix above, UU, becomes:

x1+x2+x3+x4=0x2+2x3+3x4=00=0 \begin{aligned} x_1 &+& x_2 &+& x_3 &+& x_4 &= 0 \\ && x_2 &+& 2x_3 &+& 3x_4 &= 0 \\ && && && 0 &= 0 \end{aligned}

Do back substitution with x3=1x_3 = 1 and x4=0x_4 = 0:

0=x2+2  ⟹  x2=−20=x1−2+1  ⟹  x1=1 \begin{aligned} 0 &= x_2 + 2 &\implies& x_2 = -2 \\ 0 &= x_1 -2 + 1 &\implies& x_1 = 1 \end{aligned}
A[1−210]=0 A \begin{bmatrix} 1 \\ -2 \\ 1 \\ 0\end{bmatrix} = 0

Do back substitution with x3=0x_3 = 0 and x4=1x_4 = 1:

0=x2+3  ⟹  x2=−30=x1−3+1  ⟹  x1=2 \begin{aligned} 0 &= x_2 + 3 &\implies& x_2 = -3 \\ 0 &= x_1 -3 + 1 &\implies& x_1 = 2 \end{aligned}
A[2−301]=0 A \begin{bmatrix} 2 \\ -3 \\ 0 \\ 1 \end{bmatrix} = 0

One way to write the complete solution:

x3[1−210]+x4[2−301]=[x3+2x4−2x3−3x4x3x4] x_3 \begin{bmatrix} 1 \\ -2 \\ 1 \\ 0 \end{bmatrix} + x_4 \begin{bmatrix} 2 \\ -3 \\ 0 \\ 1 \end{bmatrix} = \begin{bmatrix} x_3 + 2x_4 \\ -2x_3 - 3x_4 \\ x_3 \\ x_4 \end{bmatrix}

Row Reduced Echelon Form

However, it is quicker to "complete" elimination, and find the solution from rref. AA, UU, and RR have the same nullspace. Our example matrix, AA, is very close to rref already (the pivots are already 1).

[111101230000]  ⟹  [10−1−201230000] \begin{bmatrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 2 & 3 \\ 0 & 0 & 0 & 0 \end{bmatrix} \implies \begin{bmatrix} 1 & 0 & -1 & -2 \\ 0 & 1 & 2 & 3 \\ 0 & 0 & 0 & 0 \end{bmatrix}

Notice how if we set x3=1x_3 = 1 and x4=0x_4 = 0 we can read the values x1x_1 and x2x_2 from the third column (if we reverse the sign).

A[1−210]=0A \begin{bmatrix} 1 \\ -2 \\ 1 \\ 0\end{bmatrix} = 0

You cannot do back substitution on a matrix in rref. This yields incorrect results.