# Lab 6# Name: Omeed Zokaeim# 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.
#43@interactdefmycoordinatefunction(r=(-10,10),s=(-10,10),target=vector([2,3])):#this creates sliders for scalar by setting up an interactive functionu=r*vector([1,2])#defines the basis, our vectors u and v.v=s*vector([1,.5])wee=u+v#this calculates the sum of u + v and assigns it to our variablep=plot(u,axes_labels=["x","y"])+plot(v,color="red")+plot(wee,color="purple")+plot(target,color="yellow")+point(target,size=50,color="green")#plots vectors u and v, their sum, and our point, on the same set of axes through overlaying themshow(p)
Interact: please open in CoCalc
#44@interactdefmycoordinatefunction(r=(-10,10),s=(-10,10),target=vector([2,3])):u=r*vector([5,2])#this defines a new basis by changing our vectorsv=s*vector([3,.5])wee=[(u+v,u+v)]p=plot(u,axes_labels=["x","y"])+plot(v,color="red")+plot(u+v,color="purple")+list_plot(wee,size=50,color="yellow")+point(target,size=50,color="green")show(p)
#46t=matrix(RDF,[[1,1],[2,1/2]])#defines the 2x2 matrixt*vector([4/3,2/3])#this verifies the matrix's ability to convert from r,s to x,y corrdinates for point (2 ,3)t*vector([-4,0])#verifies for point ( -4 , -8)t*vector([-2.6,5.6])#verifies for point (3 , -2.4)
#Eigenvector u=[1,2], a multiple of (0.447213,0.894427), has an eigenvalue of -1, and eigenvector v=[1,0.5], a multiple of (0.894427,0.447213) has an eigenvalue of 5.
#The product of these matrices, that is their composition, gives us a diagonal matrix. The numbers in the diagonal correspond to the eigenvalues that we obtained in #51 and the anti-diagonal should have both numbers as zero (sage has a very small rounding error but the top right number is essentially zero).