How can I determine the dimension of a space of $2\times 2$ matrices? I've a $2\times 2$ matrix $A$ with distinct eigenvalues. I want to find the dimension of the space of all $2\times 2$ matrices $N$ such that the matrix
$M=
  [ {\begin{array}{cc}
   A & N \\      0 & A \      \end{array} ]}$
is diagonalizable. (Here $N$ and $0$ are $2\times 2$ block matrices) 
While trying to solve this, I noticed that if $\lambda_1$ and $\lambda_2$ are two eigenvalues of $A$, they are also eigenvalues of the $4\times 4$ matrix. For that to be diagonalizable, the minimal polynomial needs to have distinct roots, and using only this condition, I showed that the matrices $N$ form a subspace. However to find the dimension of the space, I likely will need to use something else. How do I solve this?
 A: The characteristic polynomial of
$$ \begin{bmatrix} A & N \\ 0 & A \end{bmatrix}$$ is the characteristic polynomial of $A$ squared. This is so because the characteristic polynomial of a block triangular matrix is the product of the characteristic polynomials of the diagonal blocks (you can find the proof elsewhere here on stackexchange). So then $M$ has characteristic polynomial $(x-\lambda_1)^2(x-\lambda_2)^2$ where $\lambda_1,\lambda_2$ are the eigenvalues of $A$.
So now the minimal polynomial of $M$ divides its characteristic polynomial, and contains each of the irreducible factors contained in the characteristic polynomial. As you know $M$ will be diagonalizable if each of the distinct factors (i.e. relatively prime with other factors) in the minimal polynomial is linear (i.e. degree one polynomials). So this means the minimal polynomial of $M$ must be $(x-\lambda_1)(x-\lambda_2)$. So now we can use Smith Canonical Form theory to find all the matrices $N$ which will allow $M$ to satisfy this condition - in short, we require the greatest common divisor among the determinants of all $3 \times 3$ submatrices of $xI-M$ to be $(x-\lambda_1)(x-\lambda_2)$. 
Let's assume for now that $A$ is in diagonal form. Let
$$N =  \begin{bmatrix} n_{11} & n_{12} \\ n_{21} & n_{22} \end{bmatrix}.$$
Then the non-zero determinants of the $3 \times 3$ submatrices of $xI-M$ are
$$ -(a-x)^2 (b-x), $$
$$ n_{22}(a-x)^2,$$
$$ -n_{12} (a-x) (b-x),$$
$$ -(a-x) (b-x)^2,$$
$$ -n_{21} (a-x) (b-x),$$
$$ n_{11} (b-x)^2, $$
$$ (x-a)^2 (-(b-x)),$$
$$ -(a-x) (b-x)^2.$$
To achieve the desired form we need the second and the sixth factor above to be zero: so $n_{11}$ and $n_{22}$ must be zero. On the other hand $n_{12}$ and $n_{21}$ can be any scalar values in the relevant field. From this we would have to conclude that the space of matrices $N$ that will allow $M$ to be diagonalizable is dimension 2. 
I suspect that (but you'd need to confirm) if $A$ is not diagonal, but $P^{-1}AP$ is, we should have by virtue of invertibility of $P$: 
$$P\begin{bmatrix} 0 &1 \\ 0 &0 \end{bmatrix}P^{-1} \text{ and } P\begin{bmatrix} 0&0 \\ 1 &0 \end{bmatrix}P^{-1}$$ are linearly independent...so the result will remain true under similarity, and therefore it is sufficient to consider $A$ as a diagonal matrix.  
