In this worksheet, we explore the primary, SN and cyclic decompositions of the following matrix.

MatrixForm[A ={{1,1,1,1,1,1,1,1},{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,-1},{0,1,1,0,0,0,0,1},{0,0,0,1,1,0,0,0},{0,1,1,1,1,1,0,1},{0,-1,-1,-1,-1,0,1,-1},{0,0,0,0,0,0,0,0}}]

First I compute the minimal polynomial of A by computing p_(T,v) for a 'suitably random' vector v.  It turns out that the following vector v = v0 is random enough:

v0={1,1,0,0,0,0,0,0}

v1=A.v0

v2=A.v1

v3=A.v2

It' s not clear at this point whether v0, v1, v2, v3 are independent vectors, so I check by making them the columns of a matrix and evaluating the nullspace.

NullSpace[Transpose[{v0,v1,v2,v3}]]

That is, the nullspace is trivial, so the vectors are independent.  I proceed one more step and check again.

v4=A.v3

NullSpace[Transpose[{v0,v1,v2,v3,v4}]]

So the vectors are now dependent, and in fact v4 - 2v3 + v2 = 0 is a dependence relation.  I infer that p_T,v(x) = x^4 - 2x^3 + x^2.  To see if this is the minimal polynomial for A, I evaluate p_T,v(A):

MatrixForm[A.A.A.A-2A.A.A + A.A]

So p_min(x) = x^4 -2 x^3 + x^2 = x^2(x-1)^2, and by the primary decomposition theorem, I know that R^4 is a direct sum of the nullspaces of A^2 and (A-I)^2.  So I find bases for these and combine them to get a basis B for R^8.

Id = IdentityMatrix[8];
{b1,b2,b3,b4}=NullSpace[A.A]
{b5,b6,b7,b8}=NullSpace[(A-Id).(A-Id)]

The change of basis matrix from B to the standard basis is

MatrixForm[CEB =Transpose[{b1,b2,b3,b4,b5,b6,b7,b8}]]

The matrix for the transformation T (x) = A x  relative to the basis B is therefore given by

MatrixForm[AB = Inverse[CEB].A.CEB]

And as expected, the matrix has two 4 x 4 blocks corresponding to the two four dimensional invariant subspaces in the primary decomposition.

MatrixForm[SB = DiagonalMatrix[{0,0,0,0,1,1,1,1}]]
MatrixForm[NB = AB-SB]

NB.NB
SB.NB-NB.SB

(EAB =DiagonalMatrix[{1,1,1,1,E,E,E,E}].(Id+NB))//MatrixForm

MatrixExp[AB]-EAB

MatrixForm[EA=CEB.EAB.Inverse[CEB]]

EA-MatrixExp[A]