CoCalc Public FilesLab 5 / Lab5-turnin.sagewsOpen with one click!
Author: Dakota Campbell
Views : 157
# Lab 1: # Name: Dakota Campbell # 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.
#33 M=matrix(RDF,[[0.57,0.5025],[0.33,0.917]]) #gives the matrix of the black bear model M.eigenvectors_right()#finding the eigenvectors
[(0.3008632979519208, [(-0.8815235799988788, 0.4721399982059986)], 1), (1.186136702048079, [(-0.6320226312996823, -0.7749499296890257)], 1)]
eigenv1=M.eigenvectors_right()[0][1][0] plot(eigenv1, color="pink")
eigenv2=M.eigenvectors_right()[1][1][0] plot(eigenv2,color="orange")
#34 mult1=M*eigenv1 #assigns variable to the multiplication of the matrix to the eigenvector
mult2=M*eigenv2
plot(eigenv1, color="pink")+plot(mult1, color="maroon")+plot(eigenv2,color="orange")+plot(mult2, color="bisque")
#35 eigenv1.norm() #length of original eigenvector
1.0
eigenv2.norm()
1.0
mult1.norm()#length of eigenvector-matrix multiple
0.3008632979519208
mult2.norm()
1.186136702048079
mult1.norm()/eigenv1.norm()
0.3008632979519208
mult2.norm()/eigenv2.norm()#ratio=eigenvalue 2
1.186136702048079
#Exercise 36 #the first value decreased #the second value increased #Exercise 37 #1 The average adult produces 35315 larvae each month #2 .949 adults survive from one month to the next #3 .00003 larvae survive to become juveniles #4 0.777 juveniles remain juveniles in the following month #38 L=matrix(RDF,[[0,0,35315],[.00003,.777,0],[0,.071,.949]]) show(L)
(0.00.035315.03×10050.7770.00.00.0710.949)\displaystyle \left(\begin{array}{rrr} 0.0 & 0.0 & 35315.0 \\ 3 \times 10^{-05} & 0.777 & 0.0 \\ 0.0 & 0.071 & 0.949 \end{array}\right)
#39 eigenv3=L.eigenvectors_right()[0][1][0] #finds the first eigenvecto eigenv3.norm()
0.9999999999999999
#this gives the length of the eigenvector eigenv3L=eigenv3*L eigenv3L.norm()
35314.99996326072
#gives length of the product of the matrix and the eigenvector eigenv4=L.eigenvectors_right()[1][1][0] #finds the second eigenvector eigenv4.norm()
1.0
#gives length of the second eigenvector eigenv4L=eigenv4*L eigenv4L.norm()
35314.999868118204
#finds the length of the product of the matrix and the eigenvector eigenv3L.norm()/eigenv3.norm()
35314.99996326073
#gives the ratio/eigenvalue for the first eigenvector eigenv4L.norm()/eigenv4.norm()
35314.999868118204
#gives the ratio/eigenvalue for the second eigenvector #this is the dominant eigenvalue/long-term growth rate of the system. The long-term growth rate of the lionfish population is about 35314.99996326073 #The system after this long-term growth rate would be: 35314.999996326073*L
[ 0.0 0.0 1247149224.8702552] [1.0594499998897822 27439.75499714536 0.0] [ 0.0 2507.364999739151 33513.93499651344]
#The system will have 1247149224.8702552 larvae, 27439.75499714536+1.0594499998897 juveniles, and 33513.93499651344+2507.364999739151 adults #Exercise 40 initial1=[vector([50,500,100])] #first set of initial conditions numIter=50 for i in srange(0,numIter): #iterates initial1.append(L*initial1[i]) #appends to the initial conditions initial1[-1]
(2025720990.0530634, 170000.91203694066, 65075.3622456219)
((2025720990.0530634/65075.3622456219),(170000.91203694066/65075.3622456219),(65075.3622456219/65075))
(31128.8469268467, 2.61236981509662, 1.00000556658658)
#Long-term proportions are 31128.8469268467 larvae, 2.61236981509662 juveniles, 1.00000000000000 adults initial2=[vector([300,222,22])] #second set of initial conditions numIter=50 for i in srange(0,numIter): #iterates initial2.append(L*initial2[i]) #appends to the initial conditions initial2[-1]
(671765324.8099924, 56375.34411365256, 21580.154458938097)
((671765324.8099924/21580.154458938097),(56375.34411365256/21580.154458938097),(21580.154458938097/21580.154458938097))
(31128.8469268467, 2.61236981509662, 1.000000000000000)
#Long-term proportions are 31128.8469268467 larvae, 2.61236981509662 juveniles,1.000000000000000 adults #Exercise 41 #For an population to be constant or declining then the dominant eigenvalue has to be equal or less than the ABSOLUTE VALUE of 1 #Exercise 42 L=matrix(RDF,[[0,0,35315/100],[0.00003,0.777,0],[0,0.071,0.949]]) L.eigenvectors_right()
[(0.0010225668835611712, [(-0.9999999992484746, 3.866091808491111e-05, -2.895559628465897e-06)], 1), (0.771506899758159, [(0.9999827006875822, -0.005461302306504318, 0.002184605842331214)], 1), (0.9534705333582801, [(0.9999963408335845, 0.00016999943080638907, 0.002699892522868261)], 1)]
listone= [vector([300, 50, 10])] numIter = 200 for i in srange(0,numIter): listone.append(L*listone[i]) listone[-1]
(0.7872677836224409, 0.00013383556483462664, 0.002125546180224493)
L=matrix(RDF,[[0,0,35315],[0.00003,0.777,0],[0,0.071,0.949/100]]) L.eigenvectors_right()
[(0.8760791407266573, [(-0.9999999538519322, -0.0003027882397398138, -2.480756336676475e-05)], 1), (-0.044794570363328734 + 0.28957616250688606*I, [(0.9999999993728483, -3.247341325828788e-05 - 1.1442672821113654e-05*I, -1.2684290056699947e-06 + 8.199806380441113e-06*I)], 1), (-0.044794570363328734 - 0.28957616250688606*I, [(0.9999999993728483, -3.247341325828788e-05 + 1.1442672821113654e-05*I, -1.2684290056699947e-06 - 8.199806380441113e-06*I)], 1)]
listone= [vector([300, 50, 10])] numIter = 200 for i in srange(0,numIter): listone.append(L*listone[i]) listone[-1]
(5.55234656434667e-07, 1.6811853202273867e-10, 1.3774019558571258e-11)
L=matrix(RDF,[[0,0,35315],[0.00003/100,0.777,0],[0,0.071,0.949]]) L.eigenvectors_right()
[(0.0010225668835612822, [(-0.9999999999999248, 3.866091811396287e-07, -2.895559630641765e-08)], 1), (0.7715068997581594, [(0.9999999982700238, -5.461396775465435e-05, 2.184643631384597e-05)], 1), (0.9534705333582801, [(0.9999999996340813, 1.7000005280266403e-06, 2.6999024012725107e-05)], 1)]
listone = [vector([300, 50, 10])] numIter = 200 for i in srange(0,numIter): listone.append(L*listone[i]) listone[-1]
(78.71695144485972, 0.00013381885906987818, 0.0021252808630459643)