선형대수응용_HW_W1

633 days 전, jongha4886 작성

x = vector([-4,-3,2,0,5,-6,-7,8]) y = vector([2,-5,-4,0,8,-9,5,11]) norm_multi = x.norm()*y.norm() xy_ip = x.inner_product(y) cos_theta = xy_ip / norm_multi theta = arccos(cos_theta) theta_degree = (theta*180/pi).n(digits=3) print "Theta is", theta_degree 
       
Theta is 56.0
Theta is 56.0
x = vector([1,-2,-3,1,7,9,8,6]) y = vector([7,-7,0,9,12,11,-5,4]) t = y.inner_product(x)/x.inner_product(x) projx_y = t*x w = y - projx_y print "x위로의 y의 정사영은", projx_y print "수직성분 w는", w 
       
x위로의 y의 정사영은 (197/245, -394/245, -591/245, 197/245, 197/35, 1773/245,
1576/245, 1182/245)
수직성분 w는 (1518/245, -1321/245, 591/245, 2008/245, 223/35, 922/245,
-2801/245, -202/245)
x위로의 y의 정사영은 (197/245, -394/245, -591/245, 197/245, 197/35, 1773/245, 1576/245, 1182/245)
수직성분 w는 (1518/245, -1321/245, 591/245, 2008/245, 223/35, 922/245, -2801/245, -202/245)