Example 2

In[35]:=
  MatrixForm[B]

Out[35]=

  2    -1   2    0
  
  0    3    -1   0
  
  0    1    1    0
  
  0    1    -3   5

The following finds the characteristic polynomial of B.

In[36]:=

  Det[B-x IdentityMatrix[4]]

Out[36]=

                  2       3    4
  40 - 68 x + 42 x  - 11 x  + x

In[37]:=

  Factor[Det[B-x IdentityMatrix[4]]]

Out[37]=

                   3
  (-5 + x) (-2 + x)

Some shortcuts.

In[38]:=

  Bm2I=B-2IdentityMatrix[4];
  Bm5I=B-5IdentityMatrix[4];

Let's check (-5+x)(-2+x).

In[39]:=

  MatrixForm[Bm5I.Bm2I]

Out[39]=

  0    4    -7   0
  
  0    -3   3    0
  
  0    -3   3    0
  
  0    -2   2    0

Let's check (-5+x)(-2+x)^2.

In[40]:=

  MatrixForm[Bm5I.Bm2I.Bm2I]

Out[40]=

  0    -3   3    0
  
  0    0    0    0
  
  0    0    0    0
  
  0    0    0    0

By default (and the Cayley-Hamilton Theorem), the minimal polynomial is the characteristic polynomial (suitably written to be monic):
(x-2)^3 (x-5)

Recall the Jordan form of B.

In[41]:=

  MatrixForm[JB]

Out[41]=

  2   1   0   0
  
  0   2   1   0
  
  0   0   2   0
  
  0   0   0   5

Compare the size of the Jordan block for each eigenvalue with the multiplicity of that eigenvalue in the MINIMAL polynomial.

Up to Jordan Form and Minimal Polynomials