Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 248
Image: ubuntu2004
Kernel: SageMath 9.2
# Name: # I worked on this code with: # Please do all of your work for this week's lab in this worksheet. If # you wish to create other worksheets for scratch work, you can, but # this is the one that will be graded. You do not need to do anything # to turn in your lab. It will be collected by your TA at the beginning # of (or right before) next week’s lab. # Be sure to clearly label which question you are answering as you go and to # use enough comments that you and the grader can understand your code.
#43a @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([2,3])): u= R*vector([1,2]) v= S*vector([1,0.5]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[2,3]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') #R= 1.35 and S=0.65
#43b @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([-5,1.2])): u= R*vector([1,2]) v= S*vector([1,0.5]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[-5,1.2]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='lower left') #R= 2.46 and S= -7.46
#43c @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([-4,-8])): u= R*vector([1,2]) v= S*vector([1,0.5]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[-4,-8]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') # R=-4 and S=0
#43d @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([3,-2.4])): u= R*vector([1,2]) v= S*vector([1,0.5]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[3,-2.4]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') # R= -2.6 and S= 5.62
#44a @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([2,3])): u= R*vector([2,3]) v= S*vector([1,0.4]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[2,3]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') # R=1 and S=0
#44b @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([-5,1.2])): u= R*vector([2,3]) v= S*vector([1,0.4]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[-5,1.2]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='lower left') # R =1.48 and S = -8
#44c @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([-4,-8])): u= R*vector([2,3]) v= S*vector([1,0.4]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[-4,-8]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='lower left') # R = -2.9 and S = 1.78
#44d @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([3,-2.4])): u= R*vector([2,3]) v= S*vector([1,0.4]) pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * v",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * v",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[3,-2.4]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='lower left') # R =1.63 and S = 6.27
#45a @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([2,3])): u= R*vector([1,2]) v= S*u pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * u",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * u",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[2,3]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') #Cannot reach the target point when u is a scalar multiple of v
#45b @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([-5,1.2])): u= R*vector([1,2]) v= S*u pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * u",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * u",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[-5,1.2]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='lower left') #Cannot reach the target point when u is a scalar multiple of v
#45c @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([-4,-8])): u= R*vector([1,2]) v= S*u pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * u",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * u",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[-4,-8]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') #We can reach the target point when u is a scalar multiple of v at R=4 and S=-2
#45d @interact def vectors(R=(-10,10,0.01),S=(-10,10,0.01), target=vector([3,-2.4])): u= R*vector([1,2]) v= S*u pu= plot(u,color="dodgerblue", legend_label="R * u",legend_color="black") pv= plot(v,color="lime", legend_label= "S * u",legend_color="black") padd= plot(u+v, color="orchid",legend_label="R * u + S * u",legend_color="black") ptarget= point(target,size=40,color="turquoise",legend_label="[3,-2.4]",legend_color="black") show(pu+pv+padd+ptarget,legend_loc='upper left') #Cannot reach the target point when u is a scalar multiple of v
#46 twobytwo= matrix([[1,1],[2,1/2]]) show(twobytwo)
(11212)\renewcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 1 & 1 \\ 2 & \frac{1}{2} \end{array}\right)
#47 show("Product:",twobytwo*vector([1.35,0.65])) #The product is very close to the target point we were trying to reach which was [2,3]
Product:(2.00000000000000,3.02500000000000)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Product:| \left(2.00000000000000,\,3.02500000000000\right)
#48 Matrix1=twobytwo*vector([2.46,-7.46]) # Target: [-5,1.2] Matrix2=twobytwo*vector([-4,0]) #Target: [-4,-8] Matrix3=twobytwo*vector([-2.6,5.62]) #Target: [3,-2.4] show("Product 1:",Matrix1) show("Product 2:",Matrix2) show("Product 3:",Matrix3)
Productx1:(5.00000000000000,1.19000000000000)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Product|\phantom{\verb!x!}\verb|1:| \left(-5.00000000000000,\,1.19000000000000\right)
Productx2:(4,8)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Product|\phantom{\verb!x!}\verb|2:| \left(-4,\,-8\right)
Productx3:(3.02000000000000,2.39000000000000)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Product|\phantom{\verb!x!}\verb|3:| \left(3.02000000000000,\,-2.39000000000000\right)
#49 M=matrix([[-1/3,2/3],[4/3,-2/3]]) show(M)
(13234323)\renewcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} -\frac{1}{3} & \frac{2}{3} \\ \frac{4}{3} & -\frac{2}{3} \end{array}\right)
#50a beep=vector([1,-6]) show("Coordinates of [R,S]:",M*beep)
Coordinatesxofx[R,S]:(133,163)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Coordinates|\phantom{\verb!x!}\verb|of|\phantom{\verb!x!}\verb|[R,S]:| \left(-\frac{13}{3},\,\frac{16}{3}\right)
#50b @interact def vecfunc(R=(-10,10,0.05),S=(-10,10,0.05),target=vector([1,-6])): u= R*vector([1,2]) v= S*vector([1,1/2]) P1= plot(u,legend_label="u",legend_color="black",color="lime") P2= plot(v,legend_label="v",legend_color="black") P3= plot(u+v,legend_label="u + v",legend_color="black",color="gold") point1= point(u+v,size=50,color="turquoise",legend_label= "u + v point",legend_color="black") point2= point(target,size=50,color="orchid",legend_label="Target: [1,-6]",legend_color="black") show(P1+P2+P3+point1+point2) # R=-4.33 and S=5.33 are the coordinates that hit the target
#51a beep=vector([-4,-8]) show("Coordinates of [R,S]:",M*beep)
Coordinatesxofx[R,S]:(4,0)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Coordinates|\phantom{\verb!x!}\verb|of|\phantom{\verb!x!}\verb|[R,S]:| \left(-4,\,0\right)
#51b @interact def vecfunc(R=(-10,10,0.05),S=(-10,10,0.05),target=vector([-4,-8])): u= R*vector([1,2]) v= S*vector([1,1/2]) P1= plot(u,legend_label="u",legend_color="black",color="lime") P2= plot(v,legend_label="v",legend_color="black") P3= plot(u+v,legend_label="u + v",legend_color="black",color="orchid") point1= point(u+v,size=30,color="turquoise",legend_label= "u + v point",legend_color="black") point2= point(target,size=50,color="gold",legend_label="Target: [1,-6]",legend_color="black") show(P1+P2+P3+point1+point2) # R=-4 and S=0 are the coordinates that hit the target
#52 show(twobytwo.inverse())
(13234323)\renewcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} -\frac{1}{3} & \frac{2}{3} \\ \frac{4}{3} & -\frac{2}{3} \end{array}\right)
#53 #The inverse matrix of T (or in my case 2 x 2 matrix) is the same as the M matrix
#54 Mtrix= matrix([[7,-4],[4,-3]]) k=Mtrix.eigenvectors_right() show(Mtrix) show(k) #The eigenvalue of (1,2) is -1 and the eigenvalue of (1,1/2) is 5
(7443)\renewcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 7 & -4 \\ 4 & -3 \end{array}\right)
[(5,[(1,12)],1),(1,[(1,2)],1)]\renewcommand{\Bold}[1]{\mathbf{#1}}\left[\left(5, \left[\left(1,\,\frac{1}{2}\right)\right], 1\right), \left(-1, \left[\left(1,\,2\right)\right], 1\right)\right]
#55 First=matrix([[1,1],[2,1/2]]) Second= matrix([[7,-4],[4,-3]]) Third= First.inverse() kek=Third*Second*First show("Diagonal Matrix of 54 with Eigenvalues:",kek) #The resulting matrix is the diagonal matrix of 54 with the eigenvalues of -1 and 5
DiagonalxMatrixxofx54xwithxEigenvalues:(1005)\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|Diagonal|\phantom{\verb!x!}\verb|Matrix|\phantom{\verb!x!}\verb|of|\phantom{\verb!x!}\verb|54|\phantom{\verb!x!}\verb|with|\phantom{\verb!x!}\verb|Eigenvalues:| \left(\begin{array}{rr} -1 & 0 \\ 0 & 5 \end{array}\right)