# Ch-7-prob-19-New-황영준

## 2219 days ago by matrix

 Traceback (click to the left of this block for traceback) ... ValueError: too many values to unpack Traceback (most recent call last): zz2=G.row(1)/G.row(1).norm() File "", line 1, in File "/tmp/tmp9IbB7r/___code___.py", line 7, in [G.mu]=A.gram_schmidt() ValueError: too many values to unpack
def proj_W_x(W, x): result = 0 for y in W: result += y.inner_product(x)/(y.norm()^2)*y return result def Gram_Schmidt(x_list): length_x = len(x_list) y_list = [x_list[0]] for i in range(1, length_x): y_list.append(x_list[i] - proj_W_x(y_list[0:i], x_list[i])) y_list = map(lambda y : y / y.norm(), y_list) return y_list x1 = vector([2,3,1,2]) x2 = vector([1,2,0,1]) x3 = vector([0,1,3,0]) GS = Gram_Schmidt((x1, x2, x3)) print(GS)
 [(1/3*sqrt(2), 1/2*sqrt(2), 1/6*sqrt(2), 1/3*sqrt(2)), (-1/6, 1/2, -5/6, -1/6), (-1/2, 1/2, 1/2, -1/2)] [(1/3*sqrt(2), 1/2*sqrt(2), 1/6*sqrt(2), 1/3*sqrt(2)), (-1/6, 1/2, -5/6, -1/6), (-1/2, 1/2, 1/2, -1/2)]
def proj_W_x(W, x): result = 0 for y in W: result += y.inner_product(x)/(y.norm()^2)*y return result def Gram_Schmidt(x_list): length_x = len(x_list) y_list = [x_list[0]] for i in range(1, length_x): y_list.append(x_list[i] - proj_W_x(y_list[0:i], x_list[i])) y_list = map(lambda y : y / y.norm(), y_list) return y_list x1 = vector([3,-2,2,-1]) x2 = vector([1,1,1,1]) x3 = vector([-2,3,4,-3]) GS = Gram_Schmidt((x1, x2, x3)) print(GS)
 [(1/2*sqrt(2), -1/3*sqrt(2), 1/3*sqrt(2), -1/6*sqrt(2)), (1/17*sqrt(34), 11/102*sqrt(34), 7/102*sqrt(34), 5/51*sqrt(34)), (-3/2*sqrt(1/17), 3/2*sqrt(1/17), 5/2*sqrt(1/17), -5/2*sqrt(1/17))] [(1/2*sqrt(2), -1/3*sqrt(2), 1/3*sqrt(2), -1/6*sqrt(2)), (1/17*sqrt(34), 11/102*sqrt(34), 7/102*sqrt(34), 5/51*sqrt(34)), (-3/2*sqrt(1/17), 3/2*sqrt(1/17), 5/2*sqrt(1/17), -5/2*sqrt(1/17))]