CoCalc Public FilesLab 5 / Lab5-turnin.sagewsOpen with one click!
Author: Alexis Zukovski User
Views : 149
# Lab 5: # Name: Alexis Zukovski # I worked on this code with: Richard Wolff # 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.
#exercise 33 BearMat = matrix(RDF,[[.57,.5025],[.33,.917]]) BearMat
[ 0.57 0.5025] [ 0.33 0.917]
BearMat.eigenvectors_right()
[(0.3008632979519208, [(-0.8815235799988788, 0.4721399982059986)], 1), (1.186136702048079, [(-0.6320226312996823, -0.7749499296890257)], 1)]
eigen1= vector([-.8815235799988788, 0.4721399982059986]) eigen2= vector([-0.6320226312996823, -0.7749499296890257]) plot(eigen1,color="pink") + plot(eigen2,color="yellow")
#exercise 34 neweigen1 = BearMat*vector([-.8815235799988788, 0.4721399982059986]) neweigen2 = BearMat*vector([-0.6320226312996823, -0.7749499296890257]) neweigen1 neweigen2 plot(vector([-.8815235799988788, 0.4721399982059986]),color="pink") + plot(vector([-0.6320226312996823, -0.7749499296890257]),color="yellow") +plot(neweigen1,color="red")+plot(neweigen2,color="orange")
(-0.2652180915008465, 0.14204959695527075) (-0.7496652395095542, -0.9191965538537317)
#still going along the same path however the red one is shorter in relation to pink and the orange one is larger in relation to yellow (pink and yellow were originals) #exercise 35 eigen1.norm()
1.00000000000000
eigen2.norm()
1.00000000000000
neweigen1.norm()
0.3008632979519208
neweigen2.norm()
1.186136702048079
neweigen1.norm()/eigen1.norm() neweigen2.norm()/eigen2.norm()
0.3008632979519208 1.186136702048079
#exercise 36 #the ratios we computed in exercise 35 are the eigenvalues of the BlackBear model!! #exercise 37 # 35315 arvae are produced every month # .949 adults are expected to survive every month # .00003 larvae survive to become semi adults # .777 larvae are expected to stay as larvae within the month #exercise 38 LionFish = matrix(RDF,[[0,0,35315],[.00003,.777,0],[0,.071,.949]]) LionFish
[ 0.0 0.0 35315.0] [ 3e-05 0.777 0.0] [ 0.0 0.071 0.949]
#exercise 39 LionFish.eigenvectors_right()
[(0.15026156162015658, [(0.9999999988453299, -4.78668582110772e-05, 4.254893429043022e-06)], 1), (0.44126018150798385, [(-0.9999999959297882, 8.935490586919178e-05, -1.2494978895992127e-05)], 1), (1.1344782568718599, [(0.9999999959626241, 8.392118765878536e-05, 3.212454346004658e-05)], 1)]
# the long term growth is 1.1344782568718599 # if the population were to exist for a long time, we would expect to see an influx of babies b/c the other eigenvectors for the other ages are much smaller and not as drastic #exercise 40 LionFish*vector([20,65,50]) #20 babies, 65 juveniles and 50 adults
(1765750.0, 50.5056, 52.065)
LionFish*vector([3,800,140]) #3 babies, 800 juveniles and 140 adults
(4944100.0, 621.60009, 189.65999999999997)
#exercise 41 # in order for the eigenvector to be constant or decrease, the dominant eigenvalue would have to be 1(if you want it to stay constant) or less than 1 (if you want it to decrease) #exercise 42 LionFishEdit1 = matrix(RDF,[[0,0,35],[.00003,.777,0],[0,.071,.949]]) #much less larvae LionFishEdit1*(vector([20,65,50])) #will simulate with same initial conditions
(1750.0, 50.5056, 52.065)
#babies have been reduced massively but adults and juveniles are still same LionFishEdit2 = matrix(RDF,[[0,0,35315],[.00003,.777,0],[0,.071,.75]]) #adults have lower survival rates LionFishEdit2*(vector([20,65,50])) #will simulate with same initial conditions
(1765750.0, 50.5056, 42.115)
#adults have gone down in numbers, babies and juveniles are at the same numbers LionFishEdit3 = matrix(RDF,[[0,0,35315],[.00003,.39,0],[0,.071,.949]]) #much less juveniles staying alive LionFishEdit3*(vector([20,65,50])) #will simulate with same initial conditions
(1765750.0, 25.3506, 52.065)
#juveniles are halfed in number LionFishEdit1.eigenvectors_right()
[(0.00010112609206125445, [(-0.9999999992502644, 3.8615064308952635e-05, -2.8893169138713e-06)], 1), (0.7764435750278308, [(0.9983048057987028, -0.053824227293821886, 0.022146495782337367)], 1), (0.9494552988801072, [(0.9996322427900908, 0.0001738941480977843, 0.027117317995670208)], 1)]
LionFishEdit2.eigenvectors_right()
[(1.0336064310796043, [(0.9999999927376475, 0.00011691055308283659, 2.9268198317236017e-05)], 1), (0.24669678446019738 + 0.10916011472859544*I, [(-0.9999999984357074, 5.427180139981193e-05 + 1.1171563538985118e-05*I, -6.985609063409076e-06 - 3.0910410465195333e-06*I)], 1), (0.24669678446019738 - 0.10916011472859544*I, [(-0.9999999984357074, 5.427180139981193e-05 - 1.1171563538985118e-05*I, -6.985609063409076e-06 + 3.0910410465195333e-06*I)], 1)]
LionFishEdit3.eigenvectors_right()
[(0.14151787185888637 + 0.22628977733938152*I, [(-0.9999999959873925, 6.599765690392691e-05 + 6.010329675391833e-05*I, -4.0073020328764185e-06 - 6.407752412045008e-06*I)], 1), (0.14151787185888637 - 0.22628977733938152*I, [(-0.9999999959873925, 6.599765690392691e-05 - 6.010329675391833e-05*I, -4.0073020328764185e-06 + 6.407752412045008e-06*I)], 1), (1.0559642562822273, [(0.9999999985383192, 4.504746264255352e-05, 2.9901295617690643e-05)], 1)]
#edit 1 made the biggest growth change because the dominant eigenvalue has become the smallest of all dom eigen values in the other edits