summaryrefslogtreecommitdiffstats
path: root/4/two.py
blob: 1302f6e1cd515249208fa4fc8b2369136b261db1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from libsolve2 import *
from fractions import Fraction

def f_eye(dim):
    return Matrix([
        [0 if i != j else 1 for i in range(dim)]
        for j in range(dim)
    ])

m = Matrix([
    [ 4,  -3,  -2,   0,   0,  0],
    [ 0,   2,  -1,   0,   0,  0],
    [ 0,   2,   5,   0,   0,  0],
    [ 1,   1,   1,   2,  -1,  0],
    [-2,  -3,  -3,   4,   6,  0],
    [ 1,   8,   7,  -5,  -3,  3]
])

print('char polynomial is  ', (m - f_eye(6) * x).det())
print('(x - 3)^2(x - 4)^4 =', (x - 3)*(x - 3)*(x - 4)*(x - 4)*(x - 4)*(x - 4))

root1 = m - f_eye(6) * 3
print(f'rank of m - 3E = {root1.rank()} => one cell of size 2')

root2 = m - f_eye(6) * 4
print(f'rank of m - 4E = {root2.rank()} => two cells')
print(f'rank of (m - 4E)^2 = {(root2@root2).rank()} => two cells of size 2')