SharedLab 06 / Lab6-turnin.sagewsOpen in CoCalc
Author: Janeane Kim
# Lab 6 # Name: Janeane M. Kim # 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 @interact def interact1(R=(-10,10), S=(-10,10),target=vector([1,1])): # defines a function with the changing variables u=R*(vector([1,2])) # gives u the multipled variable v=S*(vector([1,1/2])) p=plot(u+v, color="red")+plot(u)+plot(v) # plots the sum of all the variables f=text(str(((u+v)[0], (u+v)[1])), u+v, fontsize=15, color="red") show(p+f)
Interact: please open in CoCalc
# (R,S) is around (1.28,0.8) when the sum vector is (2,3)
# PLEASE restart and replay the code if an error message occurs! Thank you # turns out there's something wrong(?) # cannot process interacts with more than one variable without restarting the wksht immediately before
# 44 @interact def interact(R=(-10,10), S=(-10,10),target=vector([1,1])): # defines a function with the changing variables u=R*(vector([2,5])) # gives u the multipled variable v=S*(vector([0.6,9])) p=plot(u+v, color="red")+plot(u)+plot(v) # plots the sum of all the variables f=text(str(((u+v)[0], (u+v)[1])), u+v, fontsize=15, color="red") show(f+p)
Interact: please open in CoCalc
# 45 @interact def interact(R=(-10,10), S=(-10,10),target=vector([1,1])): # defines a function with the changing variables u=R*(vector([1,0])) # gives u the multipled variable v=S*(vector([0,1])) p=plot(u+v, color="red")+plot(u)+plot(v) # plots the sum of all the variables f=text(str(((u+v)[0], (u+v)[1])), u+v, fontsize=15, color="red") show(f+p)
Interact: please open in CoCalc
# making u and v scalar multiples of themselves lead to u and v missing parts of the vector
# 46 trix=matrix([[1,1],[2,1/2]]) trix
[ 1 1] [ 2 1/2]
# 47 sample=vector([1.28,0.8]) trix*sample
(2.08000000000000, 2.96000000000000)
# when multiplied by the given matrix, the derived R,S coordinates become close to the original X,Y point (2,3)
# 48 # original XY point:(4.5,7) areforkids=vector([3.12,1.4]) trix*areforkids
(4.52000000000000, 6.94000000000000)
# original XY point (-3,5) yogurt=vector([-2.28, -0.64]) trix*yogurt
(-2.92000000000000, -4.88000000000000)
# 49 W=matrix([[-1/3,2/3],[4/3,-2/3]]) W
[-1/3 2/3] [ 4/3 -2/3]
# 50 (vector([-3,5]))*W
(23/3, -16/3)
# 51 # original XY point (-5,-9) yogurt=vector([-4.38, -0.64]) trix*yogurt
(-5.02000000000000, -9.08000000000000)
# 52 trix.inverse()
(-3.02000000000000, -5.08000000000000) [-1/3 2/3] [ 4/3 -2/3]
# 53 # the T inverse is the same as the manually derived W # 54 M=matrix([[7,-4],[4,-3]]) M.eigenvectors_right()
[(5, [ (1, 1/2) ], 1), (-1, [ (1, 2) ], 1)]
# the corresponding eigenvalues of this matrix are 5, 1, and -1 a7f91e7e-c1f4-4859-8cc0-5664e1c48847 # 55