213 - A9 - Subspace, Basis and Basis Coordinates

239 days ago by Professor213

John Travis

Mississippi College

This worksheet demonstrates the idea of a 1D and 2D subspace of a 3D vector spa e.  It also exhibits the new planar coordinate system created using a given set of two basis vectors for any input third vector.

# This cell describes a 1D subspace of a 3D vector space. It a subspace with only one basis vector. var('x,y,z,u,v') num_show = 3 @interact def _(v1 = input_box(vector([3,6,2]),width=10,label='$v_1$')): G = Graphics() for k in range(num_show+1): G += arrow((k*v1[0],k*v1[1],k*v1[2]),((k+1)*v1[0],(k+1)*v1[1],(k+1)*v1[2]),color='red',width=3) G += arrow((-k*v1[0],-k*v1[1],-k*v1[2]),(-(k+1)*v1[0],-(k+1)*v1[1],-(k+1)*v1[2]),color='red',width=3) G.show(axes=true) 
       

Click to the left again to hide and once more to show the dynamic interactive window

# This cell describes a 2D subspace of a 3D vector space. It a subspace with exactly two basis vectors. var('x,y,z,u,v') num_show1 = 3 num_show2 = 3 @interact def _(v1 = input_box(vector([-3,6,2]),width=10,label='$v_1$'), v2 = input_box(vector([-3,4,1]),width=10,label='$v_2$')): G = Graphics() for k in range(num_show1): G += arrow((k*v1[0],k*v1[1],k*v1[2]),((k+1)*v1[0],(k+1)*v1[1],(k+1)*v1[2]),color='red',width=3) G += arrow((-k*v1[0],-k*v1[1],-k*v1[2]),(-(k+1)*v1[0],-(k+1)*v1[1],-(k+1)*v1[2]),color='red',width=3) for k in range(num_show2): G += arrow((k*v2[0],k*v2[1],k*v2[2]),((k+1)*v2[0],(k+1)*v2[1],(k+1)*v2[2]),color='red',width=3) G += arrow((-k*v2[0],-k*v2[1],-k*v2[2]),(-(k+1)*v2[0],-(k+1)*v2[1],-(k+1)*v2[2]),color='red',width=3) G += parametric_plot3d((num_show1*v1[0]*u+num_show2*v2[0]*v, num_show1*v1[1]*u+num_show2*v2[1]*v, num_show1*v1[2]*u+num_show2*v2[2]*v), (u, -1, 1), (v, -1, 1), mesh=True,opacity=0.6) G.show() 
       

Click to the left again to hide and once more to show the dynamic interactive window

# This cell illustrates basis coordinates for a vector in the span of a 2D subspace var('x,y,z,u,v') @interact def _(v1 = input_box(vector([3,6,2]),width=10,label='$v_1$'), v2 = input_box(vector([-1,5,3]),width=10,label='$v_2$'), v3 = input_box(vector([107/6,142/3,18]),width=10,label='$x$')): n = v1.cross_product(v2) # Compute the basis coordinates for v3 relative to v1 and v2 A = matrix([v1,v2,v3]).transpose().rref() c1 = A[0,2] c2 = A[1,2] G = Graphics() if (c1==0) & (c2==0): print "V3 is not in the span of V1 and V2" G += text3d('x is not in the span of V1 and V2',(1,1,5)) else: G += text3d('Basis Coordinates = ('+str(c1)+','+str(c2)+')',(c1,c2,5)) if (c1==0) & (c2==0): c1=1 c2=1 # Let's assume c1 and c2 are positive for now a = floor(c1)+1 b = floor(c2)+1 for k in range(a): # G += arrow((k*v1[0],k*v1[1],k*v1[2]),((k+1)*v1[0],(k+1)*v1[1],(k+1)*v1[2]),color='red',width=3) for j in range(b): here = (k*v1[0]+j*v2[0],k*v1[1]+j*v2[1],k*v1[2]+j*v2[2]) there =((k+1)*v1[0]+j*v2[0],(k+1)*v1[1]+j*v2[1],(k+1)*v1[2]+j*v2[2]) G += arrow(here,there,color='red',width=3) for k in range(b): for j in range(a): here = (k*v2[0]+j*v1[0],k*v2[1]+j*v1[1],k*v2[2]+j*v1[2]) there =((k+1)*v2[0]+j*v1[0],(k+1)*v2[1]+j*v1[1],(k+1)*v2[2]+j*v1[2]) G += arrow(here,there,color='red',width=3) G += arrow((0,0,0),(v1[0],v1[1],v1[2]),color='orange',zorder=3,width=4) G += text3d('v1',(v1[0]/2,v1[1]/2,v1[2]/2)) G += arrow((0,0,0),(v2[0],v2[1],v2[2]),color='orange',zorder=3,width=4) G += text3d('v2',(v2[0]/2,v2[1]/2,v2[2]/2)) G += arrow((0,0,0),(v3[0],v3[1],v3[2]),color='green',zorder=3,width=6) G += parametric_plot3d((c1*v1[0]*u+c2*v2[0]*v, c1*v1[1]*u+c2*v2[1]*v, c1*v1[2]*u+c2*v2[2]*v), (u, 0, 1.2), (v, 0, 1.2), mesh=True,opacity=0.6) G.show(spin=False) 
       
$v_1$ 
$v_2$ 
$x$ 

Click to the left again to hide and once more to show the dynamic interactive window