Show that a set of matrices that commute is a subspace? I am having problems with this question, would appreciate any help.
Let $$A = \begin{bmatrix}
        1 & 2 \\
        2 & 1 \\
        \end{bmatrix}$$
Show that the set of 2-by-2 matrices that commute with $A$ (i.e., matrices B
for which $AB = BA$) is a subspace of the vector space of 2-by-2 matrices, and find the dimension of and a basis for this subspace.
Right now, I am trying to show that dimension of this matrix is 4, dimension of matrices that do not commute is 2, thus dimension of matrices that do commute is 2. However, I'm not sure how I should go about proving that the dimension of matrices which do not commute is 2. Any idea how should I go about doing this? 
 A: Since the matrices that do not commute is not a subspace, we need to take an approach different from the one you outline in your last paragraph. A better approach is the one given by @Arthur in his comment to the question. We want to find all matrices $B$ where $AB=BA$. We let
$$B = \begin{bmatrix}
  a & b \\
  c & d \\
\end{bmatrix}$$
We then want
$$\begin{bmatrix}1 & 2 \\2 & 1 \\\end{bmatrix} \begin{bmatrix}a & b \\c & d \\\end{bmatrix}
=\begin{bmatrix}a & b \\c & d \\\end{bmatrix} \begin{bmatrix}1 & 2 \\2 & 1 \\\end{bmatrix}$$
$$\begin{bmatrix}a+2c & b+2d \\2a+c & 2b+d \\\end{bmatrix}
=\begin{bmatrix}a+2b & 2a+b \\c+2d & 2c+d \\\end{bmatrix}$$
Then the upper left corners give us
$$a+2c=a+2b$$
$$b=c$$
The upper right corners give us
$$b+2d=2a+b$$
$$a=d$$
This means that
$$B = \begin{bmatrix}a & b \\b & a \\\end{bmatrix}$$
Checking, we get
$$AB=\begin{bmatrix}a+2b & 2a+b \\2a+b & a+2b \\\end{bmatrix}=BA$$
so that answer is correct. We see that
$$B = a\begin{bmatrix}1 & 0 \\0 & 1 \\\end{bmatrix}+b\begin{bmatrix}0 & 1 \\1 & 0 \\\end{bmatrix}$$
Therefore we conclude that the matrices that commute with $A$ are a two-dimensional subspace of the vector space of $2$-by-$2$ matrices, with the basis
$$\left\{\begin{bmatrix}1 & 0 \\0 & 1 \\\end{bmatrix}, \begin{bmatrix}0 & 1 \\1 & 0 \\\end{bmatrix}\right\}$$
