Log in to edit a copy.
Download.
Other published documents...
p1_mrg_vector1
3071 days ago by LAC2011
#initialize vectors in R^3 a=vector([1,2,3]) a
b=vector([-1,0,5]) b
#vector sums c=a+b show(c) d=a-b show(d)
#vector plots a.plot(rgbcolor='red')+b.plot(rgbcolor='blue')+c.plot(rgbcolor='green')
3
500
/home/pub/562/cells/3/.jmol_images/sage0-size500.jmol.png?1653011582.91
/home/pub/562/cells/3/sage0-size500.jmol?1653011582.91
/home/pub/562/jsmol
notActivated
#vector magnitudes lenA=norm(a) lenB=norm(b) lenC=norm(c) lenD=norm(d) show(lenA) show(lenB) show(lenC) show(lenD)
#scalar product e=a*b e
f=sum(ai*bi for ai,bi in zip(a,b)) f
g=a.dot_product(b) g
#find theta between vector a and b using dot product theta1=arccos(e/(lenA*lenB)) show(n(theta1)) theta2=theta1*180/pi show(n(theta2))