summaryrefslogtreecommitdiffstats
path: root/4/two.py
diff options
context:
space:
mode:
Diffstat (limited to '4/two.py')
-rw-r--r--4/two.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/4/two.py b/4/two.py
new file mode 100644
index 0000000..1302f6e
--- /dev/null
+++ b/4/two.py
@@ -0,0 +1,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')
+