# 9주차 강의

## 446 days 전, mindo 작성

# 예제 1 A = matrix([[sqrt(3), 2], [0, sqrt(3)]]) B = A.transpose()*A eig = B.eigenvalues() sv = [sqrt(i) for i in eig] # 특이값 구하기 print(B.eigenvectors_right()) # A^T * A 의 고유벡터 구하기, A의 right singular vector들
 [(9, [(1, sqrt(3))], 1), (1, [(1, -1/3*sqrt(3))], 1)] [(9, [(1, sqrt(3))], 1), (1, [(1, -1/3*sqrt(3))], 1)]
G = matrix([[1, sqrt(3)], [1, -1/3*sqrt(3)]]) Vh = matrix([1/G.row(i).norm()*G.row(j) for j in range(0,2)]) # V의 전치행렬 Vh = Vh.simplify() # V의 전치행렬 표현 print Vh print U = matrix([A*Vh.row(j)/sv[j] for j in range(0, 2)]).transpose() # U print U # U의 열들을 A의 left singular vector들 print S = diagonal_matrix(sv) print S print print U*S*Vh
 [1/2*sqrt(3) 3/2] [1/2*sqrt(3) -1/2] [ 3/2 1/2] [ 1/2*sqrt(3) -1/2*sqrt(3)] [3 0] [0 1] [5/2*sqrt(3) 13/2] [ 3/2 5/2*sqrt(3)] [1/2*sqrt(3) 3/2] [1/2*sqrt(3) -1/2] [ 3/2 1/2] [ 1/2*sqrt(3) -1/2*sqrt(3)] [3 0] [0 1] [5/2*sqrt(3) 13/2] [ 3/2 5/2*sqrt(3)]
# 예제 2 - full column rank인 A의 pseudo-inverse 구하기 A = matrix([[1,1],[0,1],[1,0]]) print 'A=' print A print print 'pseudo-inverse of A=' print (A.transpose()*A).inverse()*A.transpose() # pseudo-inverse 구하기
 A= [1 1] [0 1] [1 0] pseudo-inverse of A= [ 1/3 -1/3 2/3] [ 1/3 2/3 -1/3] A= [1 1] [0 1] [1 0] pseudo-inverse of A= [ 1/3 -1/3 2/3] [ 1/3 2/3 -1/3]
# 예제 4 - 최소제곱직선 구하기 A = matrix([[1,0],[1,1],[1,2],[1,3]]) b = vector([1,3,4,4]) print (A.transpose()*A).inverse()*A.transpose()*b
 (3/2, 1) (3/2, 1)