week7

188 days ago by wldnd1217

#homework1 p1=vector([5,-2,1]) p2=vector([2,4,2]) print "vector p1p2=", p1-p2 
       
vector p1p2= (3, -6, -1)
vector p1p2= (3, -6, -1)
#homework2 A=vector([1,1,3]) B=vector([-1,-1,2]) print "vector AB=", B-A 
       
vector AB= (-2, -2, -1)
vector AB= (-2, -2, -1)
#homework3 u=vector([-3,1,2,4,4]) v=vector([4,0,-8,1,2]) w=vector([6,-1,-4,3,-5]) print "vector (2u-7w)-(8v+u)=", (2*u-7*w)-(8*v+u) 
       
vector (2u-7w)-(8v+u)= (-77, 8, 94, -25, 23)
vector (2u-7w)-(8v+u)= (-77, 8, 94, -25, 23)
#homework4 u=vector([-3,1,2,4,4]) v=vector([4,0,-8,1,2]) w=vector([6,-1,-4,3,-5]) print "vector x=", (2*u-v-w)/6 
       
vector x= (-8/3, 1/2, 8/3, 2/3, 11/6)
vector x= (-8/3, 1/2, 8/3, 2/3, 11/6)
#homework5 x=vector([-1,-2,3]) y=vector([3,-2,-1]) xy=x.inner_product(y) X=x.norm() Y=y.norm() print "cos(theta)=", xy/(X*Y) 
       
cos(theta)= -1/7
cos(theta)= -1/7
#homework6 P=vector([-1,2,1]) Q=vector([-3,-4,5]) PQ=Q-P print PQ.norm() 
       
2*sqrt(14)
2*sqrt(14)
#homework7 var('a') x=vector([a,2,-1,a]) y=vector([-a,-1,3,6]) solve(x.inner_product(y)==0,a) 
       
[a == 1, a == 5]
[a == 1, a == 5]
#homework8 var('t') P=vector([2,3,9,-3]) Q=vector([5,5,10,2]) PQ=Q-P print "vector equation=", P+PQ*t 
       
vector equation= (3*t + 2, 2*t + 3, t + 9, 5*t - 3)
vector equation= (3*t + 2, 2*t + 3, t + 9, 5*t - 3)
#homework9 n=vector([-7,1,-1]) N=n.norm() print "normal vector=", n/N 
       
normal vector= (-7/51*sqrt(51), 1/51*sqrt(51), -1/51*sqrt(51))
normal vector= (-7/51*sqrt(51), 1/51*sqrt(51), -1/51*sqrt(51))
#homework10 x=vector([2,-1,3]) y=vector([4,-1,2]) xy=x.inner_product(y) X=x.norm() Y=y.norm() print "p=", x/X*xy/X 
       
p= (15/7, -15/14, 45/14)
p= (15/7, -15/14, 45/14)