# Name: Nushrat Esha # I worked on this code with: Ryan, Xavier, and Fuijia # 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.
#46 u=vector([1,2]) v=vector([1,0.5]) T=column_matrix(RDF, [u,v]) show(T)
#47 R=1.35 S=0.65 T*vector([R, S]) # when verified, the value is very close to the point, with one of the numbers, 3.025, being slightly greater than 3
#48a # point (-5, 1.2) R=2.45 S=-7.5 T*vector([R, S])
#48b # point (-4, -8) R=-4 S=0 T*vector([R, S])
#49 # expand the equations - (1) R = X -S (2) S = 1.5*X - 0.67*Y W=matrix(RDF, [[-0.33, 0.66], [1.33, -0.66]]) show(W)
#50 W*vector([1,-6])
#50 check @interact def plotvectors(R=(-10,10, 0.1), S=(-10,10, 0.1), target=vector([1, -6])): u=R*vector([1,2]) v=S*vector([1,0.5]) p_u=plot(u, color="red", aspect_ratio=1.0, legend_label="u", legend_color="black") p_v=plot(v, color="green", legend_label="v", legend_color="black") p_s=plot(R*u+S*v, color="blue", legend_label="sum", legend_color="black") p_t=plot(target, color="black", legend_label="goal", legend_color="black") show(p_u + p_v + p_s + p_t) # the target was hit
#51 # point (3, -7) W*vector([3,-7])
#51 check @interact def plotvectors(R=(-10,10, 0.1), S=(-10,10, 0.1), target=vector([3, -7])): u=R*vector([1,2]) v=S*vector([1,0.5]) p_u=plot(u, color="red", aspect_ratio=1.0, legend_label="u", legend_color="black") p_v=plot(v, color="green", legend_label="v", legend_color="black") p_s=plot(R*u+S*v, color="blue", legend_label="sum", legend_color="black") p_t=plot(target, color="black", legend_label="goal", legend_color="black") show(p_u + p_v + p_s + p_t) # the target was hit
#52 T.inverse()
#53 # the result from number 49 and number 52 are the same, the W matrix and the inverse T matrix are equal to each other
#54 M=matrix(RDF, [[7,-4],[4,-3]]) u=vector([1,2]) v=vector([1,.5]) M.eigenvectors_right() # the eigenvalues are 5 and -1
#55 W*M*T # this is a diagonalized matrix and the eigenvalues are 5 and -1. It is a diagonal matrix because it has values that are very close to 0 on the nondiagonals and this occurs because of the rounding difference. Since this is a diagonalized matrix, this means that the eigenvalues are 5 and -1 as computed in question 54.