I am trying to diagonalize the following $\lambda-$matrix:
$$\left( \begin{array}{cccc} -\lambda -16 & -17 & 87 & -108 \\ 8 & 9-\lambda & -42 & 54 \\ -3 & -3 & 16-\lambda & -18 \\ -1 & -1 & 6 & -\lambda -8 \\ \end{array} \right)$$
I am allowed to do the following:
But this is the best I could come up to:
$$\left( \begin{array}{cccc} \lambda -1 & 0 & 0 & 0 \\ -1 & 1-\lambda & 0 & 0 \\ 0 & 0 & -3 \lambda & 2-2 \lambda \\ -3 \lambda & 0 & 3 & 1-\lambda \\ \end{array} \right)$$
Are there tricks or heuristics to do that? The final result must be a matrix with only polynomials in the diagonal, I've been trying for hours but still can't make it.


If you know the theory I would suggest you to use SageMath or Macaulay2 For SageMath:(If you use $x$ instead of $\lambda$ it would be easier.)
var('x')
M=Matrix([[first row],[second row],....,[last row]])
M.smith_form()
This should give you the smith form.