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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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)
|