<s>[INST] Making a matrix with an unknown diagonalizable I'm stuck on a question about diagonalizability of matrices and need some help moving forward.I think I made some progress but I'm also not sure if its any good.  Let $a \in \mathbb{R}$, $A$ is a matrix. For which values of $a$ is the matrix $A$ diagonalizable.
$$A:= \begin{pmatrix}
1 & 2 & 3 & 4\\
0 & 2 & a & 5\\
0 & 0 & 2 & 6\\
0 & 0 & 0 & 7 \\
\end{pmatrix} \in \mathbb{R^{4\times4}}$$
Firstly, if I'm not mistaken, any matrix whose charachteristic polynomial is a product of distinct linear factors can be diagonalized. So I simply tried to find the characteristic polynomial first.
$$ p_A(x)= \det(xE_n-A)=\det \begin{pmatrix}
x-1 & -2 & -3 & -4\\
0 & x-2 & -a & -5\\
0 & 0 & x-2 & -6\\
0 & 0 & 0 & x-7 \\
\end{pmatrix}= (x-2) \times \det \begin{pmatrix}
-2 & -a & -5 \\
x-2 & x-2 & -6 \\
0 & 0 & x-7 \\
\end{pmatrix}.$$
$$ (x-2) \times \det \begin{pmatrix}
-2 & -a & -5 \\
x-2 & x-2 & -6 \\
0 & 0 & x-7 \\
\end{pmatrix}=-a^2 x^3 + 2 a^2 x^2 - 9 a x^2 + 32 a x - 28 a - 2 x^3 + 23 x^2 - 66 x + 56.$$ Unless there is an error, this should be the characteristic polynomial. From here I just checked some simple cases like what if $a=0,a=1,a=2$ and found that if $a=2$ then $p_A(x)=-6x^3+13x^2-2x=(-x)(x-2)(6x-1).$ From here however I don't know how to generalize this for any other $a$ or if there is a way to check whether this is the only possible value for $a$.
 [/INST] Since the matrix $A$ is triangular, the eigenvalues coincide with the diagonal elements of $A$. Therefore, it is given by $p(x)=(x-1)(x-2)^2(x-7)$. Since the only repeated eigenvalue is 2, we need to make sure that the geometric multiplicity of this eigenvalue is equal to 2 to make the matrix diagonalizable.
So, we have that
$$A-2I=\begin{pmatrix}
-1 & 2 & 3 & 4\\
0 & 0 & a & 5\\
0 & 0 & 0 & 6\\
0 & 0 & 0 & 5 \\
\end{pmatrix} $$
One can see that if $a\ne0$, then this matrix has rank 3, which would mean that the kernel has dimension 1 and that the eigenvalue 2 has geometric multiplicity 1, which we do not want. Therefore, $a$ must be equal to 0.
</s>