Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Example showing two interpretations of Mx = b.

718 views
ubuntu2004
Kernel: Python 3 (system-wide)
x,y,z,t = var('x,y,z,t') M = matrix([[1,2,3],[2,-3,1],[1,1,0]]) v = matrix([x,y,z]).transpose() F = M*v p = matrix([1,1,1]).transpose() b = M*p

This first example shows the interpretation of the system Mx=bM\mathbf{x}=\mathbf{b} as the intersection of planes where [123231110][xyz]=[602]\begin{bmatrix}1&2&3\\2&-3&1\\1&1&0\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix}=\begin{bmatrix}6\\0\\2\end{bmatrix} is viewed as a system of equations x+2y+3z=62x3y+z=0x+y=2\begin{alignat}{7} & &&x &&+ 2&&y &&+3&&z &&=6\\ &2&&x &&- 3&&y &&+ &&z &&=0\\ & &&x &&+ &&y && && &&= 2 \end{alignat} The solution here is x=1,y=1,z=1x=1, y=1, z=1

G = implicit_plot3d(F[0][0] == 6, (x,-4,4), (y, -4,4), (z, -4, 4), color='green', opacity='0.7', aspect_ratio=[1,1,1]) G += implicit_plot3d(F[1][0] == 0, (x,-4,4), (y, -4,4), (z, -4, 4), color='red', opacity='0.7') G += implicit_plot3d(F[2][0] == 2, (x,-4,4), (y, -4,4), (z, -4, 4), color='blue', opacity='0.7') G += sphere((1,1,1), size=.1, color='yellow', opacity='1') G.show(fig_size=4)

This next example shows the interpretation of the system Mx=bM\mathbf{x}=\mathbf{b} as a linear combination of column vectors where [123231110][xyz]=[602]\begin{bmatrix}1&2&3\\2&-3&1\\1&1&0\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix}=\begin{bmatrix}6\\0\\2\end{bmatrix} is viewed as x[121]+y[231]+z[310]=[602]x\cdot\begin{bmatrix}1\\2\\1\end{bmatrix}+ y\cdot \begin{bmatrix}2\\-3\\1\end{bmatrix}+ z\cdot\begin{bmatrix}3\\1\\0\end{bmatrix}=\begin{bmatrix}6\\0\\2\end{bmatrix} As above the solution here is x=1,y=1,z=1x=1, y=1, z=1. In the plot I denote v1=[121]\mathbf{v_1}=\begin{bmatrix}1\\2\\1\end{bmatrix}, v2=[231]\mathbf{v_2}=\begin{bmatrix}2\\-3\\1\end{bmatrix}, and v3=[310]\mathbf{v_3}=\begin{bmatrix}3\\1\\0\end{bmatrix}, so that we are solving for x,yx,y, and zz, in xv1+yv2+zv3=bx\mathbf{v_1}+y\mathbf{v_2}+z\mathbf{v_3}=\mathbf{b}.

O = vector((0,0,0)) v1 = vector(M.transpose()[0]) v2 = vector(M.transpose()[1]) v3 = vector(M.transpose()[2]) xax = vector([7,0,0]) yax = vector([0,7,0]) zax = vector([0,0,7]) b = vector(b) p = vector((1,1,1)) G = implicit_plot3d(x+y+z == 100, (x,-6,6), (y, -6,6) , (z, -6,6),frame=False) # Draw axes G += arrow(O,xax,width=1,color='black') G += arrow(O,yax,width=1,color='black') G += arrow(O,zax,width=1,color='black') G += text3d("x",1.1*xax) G += text3d("y",1.1*yax) G += text3d("z",1.1*zax) # Draw vectors G += arrow(O, v1, width=4) G += arrow(O, v2, width=4, color='yellow') G += arrow(O, v3, width=4, color='green') G += arrow(O, v1 + v2, color='orange', width=2) G += arrow(v1, v1 + v2, color='yellow', width=2) G += arrow(v1 + v2, v1 + v2 + v3, color='green', width=2) G += text3d("v₁ + v₂", 1.1*(v1+v2)) G += text3d("b = 1∙v₁ + 1∙v₂ + 1∙v₃", 1.1*(v1 + v2 + v3)) G += text3d("v₁",v1) G += text3d("v₂",v2) G += text3d("v₃",v3) G += arrow(O, v1+v2+v3, color='red',width=4) G.show(aspect_ratio=[1,1,1])