summaryrefslogtreecommitdiffstats
path: root/four.py
diff options
context:
space:
mode:
authorsyn <isaqtm@gmail.com>2020-02-16 11:56:52 +0300
committersyn <isaqtm@gmail.com>2020-02-16 11:56:52 +0300
commitfd78d0fd00e6b98ae8b9894db8be028575e205ac (patch)
treeee9dd35e871d222aa60a1958e9b6f28eaa6ecc54 /four.py
downloadalg3-fd78d0fd00e6b98ae8b9894db8be028575e205ac.tar.gz
Init commit
Diffstat (limited to 'four.py')
-rw-r--r--four.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/four.py b/four.py
new file mode 100644
index 0000000..4f7cd54
--- /dev/null
+++ b/four.py
@@ -0,0 +1,55 @@
+from libsolve import *
+from fractions import Fraction
+import numpy as np
+
+FOUR_SIMEQ = '\\overset{{\\texttt{{two.py}}}}\\simeq'
+
+# generate figure as plain file, so we can \input it
+def gen_figure(figname, text):
+ with open(f'figures/fig_four_{figname}.tex', 'w') as fd:
+ fd.write('$$' + text + '$$')
+
+A = Matrix([
+ [-1, 1, 1, -1],
+ [-7, 4, 4, -3],
+ [4, -1, -2, 1],
+ [4, -1, -2, 1]
+])
+
+lbdE = Matrix([
+ [Poly([0, 1]), 0, 0, 0],
+ [0, Poly([0, 1]), 0, 0],
+ [0, 0, Poly([0, 1]), 0],
+ [0, 0, 0, Poly([0, 1])]
+])
+
+# uncomment to see characteristic poly
+#print((A - lbdE).det())
+
+
+
+A = A - Matrix([
+ [1, 0, 0, 0],
+ [0, 1, 0, 0],
+ [0, 0, 1, 0],
+ [0, 0, 0, 1]
+])
+
+A = A@A
+
+before = A.to_tex()
+
+A.triangulate()
+
+A.make_D(0, -1)
+A.make_U(1, 2)
+A.make_D(1, Fraction(1, 4))
+
+gen_figure('fsr_A_T',
+f'''
+ {before}
+ {FOUR_SIMEQ}
+ {A.to_tex()}
+''')
+
+print(A) \ No newline at end of file