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)