LA.Ch8.Ex14.NEW.SC.Kim

2024 days ago by seongchan

A = matrix(4,5, [1,0,0,0,1,0,7,0,0,0,0,0,3,0,0,0,0,0,2,0]) B = A.transpose() C= B*A D= A*B eig_C = C.eigenvalues() eig_D = D.eigenvalues() F=matrix([[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[1,0,0,0,1],[1,0,0,0,-1]]) G=matrix([1/F.row(j).norm()*F.row(j) for j in range(0,5)]) Vt=G.simplify() H=matrix([[0,1,0,0],[0,0,1,0],[0,0,0,1],[1,0,0,1]]) J=matrix([1/H.row(j).norm()*H.row(j) for j in range(0,4)]) U=J.simplify().transpose() sv=[sqrt(i) for i in eig_C] S=diagonal_matrix(sv) K=matrix([[7,0,0,0,0],[0,3,0,0,0],[0,0,2,0,0],[0,0,0,sqrt(2),0]]) print "A=" print A print print "A^{T}=" print B print print "A^{T}*A=" print C print print "Eigenvalues & Eigenvectors of A^{T}*A" print eig_C print C.eigenvectors_right() print print "V^T=" print Vt print print "A*A^{T}=" print D print print "Eigenvalues & Eigenvectors of A*A^{T}" print eig_D print D.eigenvectors_right() print print "U=" print U print print "S=" print S print "sigma=" print K print print "U*(sigma)*Vt=" print U*K*Vt 
       
A=
[1 0 0 0 1]
[0 7 0 0 0]
[0 0 3 0 0]
[0 0 0 2 0]

A^{T}=
[1 0 0 0]
[0 7 0 0]
[0 0 3 0]
[0 0 0 2]
[1 0 0 0]

A^{T}*A=
[ 1  0  0  0  1]
[ 0 49  0  0  0]
[ 0  0  9  0  0]
[ 0  0  0  4  0]
[ 1  0  0  0  1]

Eigenvalues & Eigenvectors of A^{T}*A
[49, 9, 4, 2, 0]
[(49, [
(0, 1, 0, 0, 0)
], 1), (9, [
(0, 0, 1, 0, 0)
], 1), (4, [
(0, 0, 0, 1, 0)
], 1), (2, [
(1, 0, 0, 0, 1)
], 1), (0, [
(1, 0, 0, 0, -1)
], 1)]

V^T=
[           0            1            0            0            0]
[           0            0            1            0            0]
[           0            0            0            1            0]
[ 1/2*sqrt(2)            0            0            0  1/2*sqrt(2)]
[ 1/2*sqrt(2)            0            0            0 -1/2*sqrt(2)]

A*A^{T}=
[ 2  0  0  0]
[ 0 49  0  0]
[ 0  0  9  0]
[ 0  0  0  4]

Eigenvalues & Eigenvectors of A*A^{T}
[49, 9, 4, 2]
[(49, [
(0, 1, 0, 0)
], 1), (9, [
(0, 0, 1, 0)
], 1), (4, [
(0, 0, 0, 1)
], 1), (2, [
(1, 0, 0, 0)
], 1)]

U=
[          0           0           0 1/2*sqrt(2)]
[          1           0           0           0]
[          0           1           0           0]
[          0           0           1 1/2*sqrt(2)]

S=
[      7       0       0       0       0]
[      0       3       0       0       0]
[      0       0       2       0       0]
[      0       0       0 sqrt(2)       0]
[      0       0       0       0       0]
sigma=
[      7       0       0       0       0]
[      0       3       0       0       0]
[      0       0       2       0       0]
[      0       0       0 sqrt(2)       0]

U*(sigma)*Vt=
[1/2*sqrt(2)           0           0           0 1/2*sqrt(2)]
[          0           7           0           0           0]
[          0           0           3           0           0]
[1/2*sqrt(2)           0           0           2 1/2*sqrt(2)]
A=
[1 0 0 0 1]
[0 7 0 0 0]
[0 0 3 0 0]
[0 0 0 2 0]

A^{T}=
[1 0 0 0]
[0 7 0 0]
[0 0 3 0]
[0 0 0 2]
[1 0 0 0]

A^{T}*A=
[ 1  0  0  0  1]
[ 0 49  0  0  0]
[ 0  0  9  0  0]
[ 0  0  0  4  0]
[ 1  0  0  0  1]

Eigenvalues & Eigenvectors of A^{T}*A
[49, 9, 4, 2, 0]
[(49, [
(0, 1, 0, 0, 0)
], 1), (9, [
(0, 0, 1, 0, 0)
], 1), (4, [
(0, 0, 0, 1, 0)
], 1), (2, [
(1, 0, 0, 0, 1)
], 1), (0, [
(1, 0, 0, 0, -1)
], 1)]

V^T=
[           0            1            0            0            0]
[           0            0            1            0            0]
[           0            0            0            1            0]
[ 1/2*sqrt(2)            0            0            0  1/2*sqrt(2)]
[ 1/2*sqrt(2)            0            0            0 -1/2*sqrt(2)]

A*A^{T}=
[ 2  0  0  0]
[ 0 49  0  0]
[ 0  0  9  0]
[ 0  0  0  4]

Eigenvalues & Eigenvectors of A*A^{T}
[49, 9, 4, 2]
[(49, [
(0, 1, 0, 0)
], 1), (9, [
(0, 0, 1, 0)
], 1), (4, [
(0, 0, 0, 1)
], 1), (2, [
(1, 0, 0, 0)
], 1)]

U=
[          0           0           0 1/2*sqrt(2)]
[          1           0           0           0]
[          0           1           0           0]
[          0           0           1 1/2*sqrt(2)]

S=
[      7       0       0       0       0]
[      0       3       0       0       0]
[      0       0       2       0       0]
[      0       0       0 sqrt(2)       0]
[      0       0       0       0       0]
sigma=
[      7       0       0       0       0]
[      0       3       0       0       0]
[      0       0       2       0       0]
[      0       0       0 sqrt(2)       0]

U*(sigma)*Vt=
[1/2*sqrt(2)           0           0           0 1/2*sqrt(2)]
[          0           7           0           0           0]
[          0           0           3           0           0]
[1/2*sqrt(2)           0           0           2 1/2*sqrt(2)]