CoCalc Public FilesLab 8 / Lab8-turnin.ipynbOpen with one click!
Author: Nushrat Esha
Views : 115
Compute Environment: Ubuntu 20.04 (Default)
In [ ]:
# Name: Nushrat Esha # I worked on this code with: Ryan, Xavier # 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.
In [ ]:
#1 # The mangrove life cycle starts off with a zygote oopulation that is in the form of female gametophytes. The zygotes then become propagule, the seed stage, that grows when it finds a favorable place. The cycle is complete with the cotyledons stage which is the first leaves that form when the seed sprouts.
In [1]:
#2 M = matrix (RDF, [[0,0,0,0,0,500,1000], [0.200, 0.666, 0, 0, 0, 0, 0], [0, 0.083, 0.825, 0, 0, 0, 0], [0, 0, 0.010, 0.909, 0, 0, 0], [0, 0, 0, 0.073, 0.963, 0, 0], [0, 0, 0, 0, 0.008, 0.980, 0], [0, 0, 0, 0, 0, 0.012, 0.999]]) show (M)
(0.00.00.00.00.0500.01000.00.20.6660.00.00.00.00.00.00.0830.8250.00.00.00.00.00.00.010.9090.00.00.00.00.00.00.0730.9630.00.00.00.00.00.00.0080.980.00.00.00.00.00.00.0120.999)\left(\begin{array}{rrrrrrr} 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 500.0 & 1000.0 \\ 0.2 & 0.666 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.083 & 0.825 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.01 & 0.909 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.073 & 0.963 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.008 & 0.98 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.012 & 0.999 \end{array}\right)
In [10]:
#3 ics=vector([1,2,3,4,5,6,7]) juvs=[ics] adults=[juvs[0][5]] for i in srange (0,30,1): juvs.append(M*juvs[i]) adults.append(juvs[-1][5]) list_plot(adults, axes_labels = ["Time (months)", "Number of Old Trees"])
In [11]:
ics=vector([10,20,30,40,50,60,70]) juvs=[ics] adults=[juvs[0][5]] for i in srange (0,30,1): juvs.append(M*juvs[i]) adults.append(juvs[-1][5]) list_plot(adults, axes_labels =["Time (months)", "Number of Old Trees"])
In [12]:
ics=vector([11,12,13,14,15,16,17]) juvs=[ics] adults=[juvs[0][5]] for i in srange (0,30,1): juvs.append(M*juvs[i]) adults.append(juvs[-1][5]) list_plot(adults, axes_labels =["Time (months)", "Number of Old Trees"])
In [24]:
#4 M.eigenvectors_right() print("Eigenvalues are: ", M.eigenvalues()) print("Dominant eigenvalue is: ", max(M.eigenvalues())) print("Long term growth is: ", max(M.eigenvalues())-1) # Since the dominant eigenvalue is greater than 1, the mangrove population will increase in the long run.
Eigenvalues are: [-0.00010030692269824559, 0.6977929774359556, 0.7357303604263571, 0.9426746100629235 + 0.09655738548038885*I, 0.9426746100629235 - 0.09655738548038885*I, 1.048140178442451, 0.9750875704920878] Dominant eigenvalue is: 1.048140178442451 Long term growth is: 0.04814017844245111
In [2]:
#5 eigenvector = M.eigenvectors_right() domeigen = eigenvector[5][1] answer5=(1000)/(domeigen[0][6]) answer5*domeigen[0]
(2907538.035256681, 1521712.8160181341, 566021.6130107614, 40679.9545139918, 34879.380497523496, 4095.0148702043084, 999.9999999999999)
In [3]:
#6 dom0 = M.eigenvalues()[5] # increase everything by 50% # increase medium age tree survival rate M1 = copy(M) M1[5,5] = M1[5,5]*1.5 dom1 = M1.eigenvalues()[5] # increase sapling survival rate M1 = copy(M) M1[4,4] = M1[4,4]*1.5 dom2 = M1.eigenvalues()[5] # increase seedling survival rate M1 = copy(M) M1[3,2] = M1[3,2]*1.5 dom3 = M1.eigenvalues()[5] table([["Model:", "Dominant Eigenvalue", "Change in Dominant Eigenvalue"], ["0. Original Model",str(dom0),""], ["1. Increase medium tree survival rate by 50%",str(dom1), str(dom1-dom0)], ["2. Increase sapling survival rate by 50%",str(dom2), str(dom2-dom0)], ["3. Increase seedling survival rate by 50%",str(dom3), str(dom3-dom0)]]) # the change in the survival rate of the medium trees is greatest so this is the parameter that should be focused on being changed since it has the greatest effect on the eigenvalue in compared to the other parameters.
Model: Dominant Eigenvalue Change in Dominant Eigenvalue
0. Original Model 1.048140178442451
1. Increase medium tree survival rate by 50% 0.9539741206029235 - 0.030785515886483723*I -0.09416605783952758 - 0.030785515886483723*I
2. Increase sapling survival rate by 50% 0.9753427574529419 + 0.020878984268584876*I -0.07279742098950925 + 0.020878984268584876*I
3. Increase seedling survival rate by 50% 1.0570185342458596 0.008878355803408455
In [7]:
#7 if we had 500 older trees, how many individuals would we have in the other stages? eigenvector = M.eigenvectors_right() domeigen = eigenvector[5][1] answer6=(500)/(domeigen[0][6]) answer6*domeigen[0]
(1453769.0176283405, 760856.4080090671, 283010.8065053807, 20339.9772569959, 17439.690248761748, 2047.5074351021542, 499.99999999999994)
In [ ]:
#8 # Yes because both this lab and the graph show that the system's grows in its long-term behavior.