How can I find the dimension of an eigenspace? I have the following square matrix 
$$ A = \begin{bmatrix} 2 & 0 & 0 \\ 6 & -1 & 0 \\ 1 & 3 &-1 \end{bmatrix} $$
I found the eigenvalues:


*

*$2$ with algebraic and geometric multiplicity $1$ and eigenvector $(1,2,7/3)$. 

*$-1$ with algebraic multiplicity $2$ and geometric multiplicity $1$; one eigenvector is $(0,0,1)$.
Thus, matrix  $A$ is not diagonizable. My questions are:


*

*How can I find the Jordan normal form? 

*How I can find the dimension of the eigenspace of eigenvalue $-1$? 

*In Sagemath, how can I find the dimension of the eigenspace of eigenvalue $-1$?
 A: Most  Jordan Normal Form questions, in integers, intended to be done by hand, can be settled with the minimal polynomial. The characteristic polynomial is $\lambda^3 - 3 \lambda - 2 = (\lambda -2)(\lambda + 1)^2.$ the minimal polynomial is the same, which you can confirm by checking that $A^2 - A - 2 I \neq 0.$ Each linear factor of the characteristic polynomial must appear in the minimal polynomial, which exponent at least one, so the quadratic shown is the only possible alternative as minimal. 
Next,
$$
A+I =
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
6 & 0 & 0 \\
1 & 3 & 0
\end{array}
\right)
$$
with genuine eigenvector $t(0,0,1)^T$ with convenient multiplier $t$ if desired.
$$
(A+I)^2 =
\left(
\begin{array}{rrr}
9 & 0 & 0 \\
18 & 0 & 0 \\
21 & 0 & 0
\end{array}
\right)
$$
The description I like is that we now take $w$ with $(A+I)w \neq 0$ and $(A+I)^2 w = 0.$ I choose
 $$
w =
\left(
\begin{array}{r}
0 \\
1 \\
0 
\end{array}
\right)
$$
This $w$ will be the right hand column of $P$ in $P^{-1}A P = J.$ The middle column is $$ v = (A+I)w, $$
so that $v \neq 0$ but $(A+I)v = (A+I)^2 w = 0$ and $v$ is a genuine eigenvector. You already had the $2$ eigenvector, I take a multiple to give integers. i like integers.
$$
P =
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
6 & 0 & 1 \\
7 & 3 & 0
\end{array}
\right)
$$
with 
$$
P^{-1} =
\frac{1}{9}
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
-7 & 0 & 3 \\
-18 & 9 & 0
\end{array}
\right)
$$
leading to
$$
\frac{1}{9}
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
-7 & 0 & 3 \\
-18 & 9 & 0
\end{array}
\right)
\left(
\begin{array}{rrr}
2 & 0 & 0 \\
6 & -1 & 0 \\
1 & 3 & -1
\end{array}
\right)
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
6 & 0 & 1 \\
7 & 3 & 0
\end{array}
\right) =
\left(
\begin{array}{rrr}
2 & 0 & 0 \\
0 & -1 & 1 \\
0 & 0 & -1
\end{array}
\right)
$$
It is the reverse direction $PJP^{-1} = A$ that allows us to evaluate functions of $A$ such as $e^{At},$
$$
\frac{1}{9}
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
6 & 0 & 1 \\
7 & 3 & 0
\end{array}
\right) 
\left(
\begin{array}{rrr}
2 & 0 & 0 \\
0 & -1 & 1 \\
0 & 0 & -1
\end{array}
\right)
\left(
\begin{array}{rrr}
3 & 0 & 0 \\
-7 & 0 & 3 \\
-18 & 9 & 0
\end{array}
\right) =
\left(
\begin{array}{rrr}
2 & 0 & 0 \\
6 & -1 & 0 \\
1 & 3 & -1
\end{array}
\right)
$$
A: The SageMath commands to compute anything about this matrix
are easy to discover.
Define the matrix:
sage: a = matrix(ZZ, 3, [2, 0, 0, 6, -1, 0, 1, 3, -1])

and then type a.jor<TAB> and then a.eig<TAB>, where
<TAB> means hit the TAB key. This will show you the
methods that can be applied to a that start with jor
and with eig.
Then, once you found the method a.jordan_form, read its
documentation by typing a.jordan_form? followed by TAB
or ENTER.
You will find that you can call a.jordan_form() to get
the Jordan form, or a.jordan_form(transformation=True)
to also get the transformation matrix.
sage: j, p = a.jordan_form(transformation=True)
sage: j
[ 2| 0  0]
[--+-----]
[ 0|-1  1]
[ 0| 0 -1]
sage: p
[  1   0   0]
[  2   0   1]
[7/3   3   0]

Here is an exploration of the eigenvalues, eigenspaces,
eigenmatrix, eigenvectors.
sage: a.eigenvalues()
[2, -1, -1]
sage: a.eigenspaces_right()
[
(2, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[  1   2 7/3]),
(-1, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[0 0 1])
]
sage: a.eigenmatrix_right()
(
[ 2  0  0]  [  1   0   0]
[ 0 -1  0]  [  2   0   0]
[ 0  0 -1], [7/3   1   0]
)
sage: j, p
(
[ 2| 0  0]               
[--+-----]  [  1   0   0]
[ 0|-1  1]  [  2   0   1]
[ 0| 0 -1], [7/3   3   0]
)
sage: a.eigenvectors_right()
[(2, [
  (1, 2, 7/3)
  ], 1), (-1, [
  (0, 0, 1)
  ], 2)]

