-
Notifications
You must be signed in to change notification settings - Fork 1
/
diagonalization_demo.py
63 lines (43 loc) · 1.18 KB
/
diagonalization_demo.py
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
56
57
58
59
60
61
62
63
from detviz import *
print (''' The determinant is the area of a unit square that you see in the plot ''')
def draw_and_show(m, plt_name = "GRAPH"):
plot_setup(plt_name)
draw_matrix(m, "maroon", 0.5, "-", llgram = True)
draw_axes_for_matrix(m, "red", 0.1, "-")
plt.show()
## main ########################################################################
## I
I = [[1, 0], [0, 1]]
## A
A = [[1, 0], [5, 6]]
## S (made of eigen vectors)
S = [[1, 0], [1, 1]]
## SINV
SINV = [[1, 0], [-1, 1]]
## Diagonal L
L = [[1, 0], [0, 6]]
## S*L
SL = [[1, 0], [6, 6]]
## S*L*SINV
SLSINV = [[1, 0], [5, 6]]
plot_setup("diagonalization")
draw_matrix(A, "maroon", 0.5, "-", llgram = True)
draw_matrix(S, "green", 0.9, "-", llgram = True)
draw_matrix(SINV, "yellow", 0.9, "-", llgram = True)
draw_matrix(SL, "cyan", 0.5, "-", llgram = True)
plt.show()
## Draw unit vectors ###########################################################
#draw_and_show(I, "MATRIX - I")
#
### A
#draw_and_show(A, "A")
#
### S
#draw_and_show(S, "S")
#
### SL
#draw_and_show(SL, "S*L")
#
### SLSINV
#draw_and_show(SLSINV, "SLSINV")
################################################################################