(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 11586, 402]*) (*NotebookOutlinePosition[ 12639, 438]*) (* CellTagsIndexPosition[ 12595, 434]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{Cell[TextData["CHAPTER 4"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{Cell[TextData["1"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{Cell[TextData["1a"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Set up the Leslie matrix:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["L=Table[0,{7},{7}];"], "Input", AspectRatioFixed->True], Cell[TextData[ "L[[1]]={.32,.57,.57,.57,.57,.57,.57};\n\ L[[2,1]]=.46;L[[3,2]]=.77;L[[4,3]]=.65;\n\ L[[5,4]]=.67;L[[6,5]]=.64;L[[7,6]]=.88;"], "Input", AspectRatioFixed->True], Cell[TextData["TableForm[L]"], "Input", AspectRatioFixed->True], Cell[TextData["Iterate for 50 generations:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "n[0]={10,10,10,10,10,10,10};\nDo[n[t]=L.n[t-1],{t,50}]"], "Input", AspectRatioFixed->True], Cell[TextData[ "Find the total population size, and its ratio in successive generations:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Do[tot[t]=Apply[Plus,n[t]],{t,0,50}]"], "Input", AspectRatioFixed->True], Cell[TextData["Table[tot[t]/tot[t-1],{t,50}]"], "Input", AspectRatioFixed->True], Cell[TextData["Find the age distribution in successive generations:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["age=Table[100.0 n[t]/tot[t],{t,0,50}];"], "Input", AspectRatioFixed->True], Cell[TextData["TableForm[N[age,4]]"], "Input", AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["1b"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Find the eigenvalues and eigenvectors and display the eigenvalues and their \ absolute values:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["{vals,vecs}=Eigensystem[L];"], "Input", AspectRatioFixed->True], Cell[TextData["vals"], "Input", AspectRatioFixed->True], Cell[TextData["Abs[vals]"], "Input", AspectRatioFixed->True], Cell[TextData[ "Find the stable age distribution from the eigenvector corresponding to the \ dominant eigenvalue:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["newage=100 vecs[[1]]/Apply[Plus,vecs[[1]]]"], "Input", AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["1c"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "The left eigenvectors of a matrix are the right eigenvectors of its \ transpose."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["{lvals,lvecs}=Eigensystem[Transpose[L]];"], "Input", AspectRatioFixed->True], Cell[TextData["lvals"], "Input", AspectRatioFixed->True], Cell[TextData["repvalue=lvecs[[1]]/lvecs[[1,1]]"], "Input", AspectRatioFixed->True]}, Open]]}, Open]], Cell[CellGroupData[{Cell[TextData["2"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{Cell[TextData["2a"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "Set up the l[[x]] and m[[x]] vectors and define the function of lambda, \ f[", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox["] = ", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[CapitalSigma]\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Dash]x ", Evaluatable->False, AspectRatioFixed->True, FontSize->10, FontVariations->{"CompatibilityType"->"Superscript"}], StyleBox["l[[x]] m[[x]]:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "temp={.25,.46,.77,.65,.67,.64,.88};\n\ l=Table[Product[temp[[i]],{i,x}],{x,7}];"], "Input", AspectRatioFixed->True], Cell[TextData["m={1.28,2.28,2.28,2.28,2.28,2.28,2.28};"], "Input", AspectRatioFixed->True], Cell[TextData["f[lambda_]:=Sum[lambda^(-x)*l[[x]]*m[[x]],{x,7}]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Plot this function of ", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox[" to establish the root approximately, and then use ", Evaluatable->False, AspectRatioFixed->True], StyleBox["FindRoot", Evaluatable->False, AspectRatioFixed->True, FontWeight->"Bold"], StyleBox[" to find it exactly given its approximate value:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Plot[f[lambda],{lambda,.9,1.1}]"], "Input", AspectRatioFixed->True], Cell[TextData["FindRoot[f[lambda]==1,{lambda,1}]"], "Input", AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["2b"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["c=Table[1.0385^(-x)*l[[x]],{x,7}];"], "Input", AspectRatioFixed->True], Cell[TextData["c=100 c/Apply[Plus,c]"], "Input", AspectRatioFixed->True]}, Open]]}, Open]], Cell[CellGroupData[{Cell[TextData["3"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Calculate the mean age and estimate the annual mortality q and survival p. \ Hence find the expected numbers at different ages from the geometric \ distribution."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["freq={92,37,22,12,6,3};"], "Input", AspectRatioFixed->True], Cell[TextData["mean=Range[6].freq/172 //N"], "Input", AspectRatioFixed->True], Cell[TextData["q=1/mean"], "Input", AspectRatioFixed->True], Cell[TextData["p=1-q;"], "Input", AspectRatioFixed->True], Cell[TextData["expected=Table[172*q*p^(i-1),{i,6}];"], "Input", AspectRatioFixed->True], Cell[TextData["expected[[6]]+=172-Apply[Plus,expected];"], "Input", AspectRatioFixed->True], Cell[TextData[ "The last step adds the expected numbers for ages 7+ to those of age 6. Now \ print out the the expected distribution to compare with the observed \ distribution, and calculate the chi-square criterion of goodness of fit."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["expected"], "Input", AspectRatioFixed->True], Cell[TextData["chisquare=Apply[Plus,(freq-expected)^2/expected]"], "Input", AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["4"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["See Exercise 1"], "Text", Evaluatable->False, AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["5"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Sum[x*1.0385^(-x)*l[[x]]*m[[x]],{x,7}]"], "Input", AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["6"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{Cell[TextData["6a"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Define f[", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox["] and then solve f[", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox[ "] = 1; it may be assumed that the root is approximately 1, though you \ could plot the function to confirm this before using ", Evaluatable->False, AspectRatioFixed->True], StyleBox["FindRoot", Evaluatable->False, AspectRatioFixed->True, FontWeight->"Bold"], StyleBox[".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["f[lambda_]:=.01733 lambda^(-3)/(1-.942 lambda^(-1))"], "Input", AspectRatioFixed->True], Cell[TextData["FindRoot[f[lambda]==1,{lambda,1}]"], "Input", AspectRatioFixed->True], Cell[TextData["Changing the age of first breeding from 3 to 4 years:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "f[lambda_]:=.01733*.942 lambda^(-4)/(1-.942 lambda^(-1))"], "Input", AspectRatioFixed->True], Cell[TextData["FindRoot[f[lambda]==1,{lambda,1}]"], "Input", AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData["6b"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Define the function g in Equation 31 and then write the vector of parameters \ as a replacement list:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Clear[l,m,p]"], "Input", AspectRatioFixed->True], Cell[TextData["g=l*m*lambda^(-3)/(1-p/lambda);"], "Input", AspectRatioFixed->True], Cell[TextData["params={lambda->.9608,l->.0722,m->.24,p->.942};"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Find the sensitivity of ", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox[ " to changes in m from Equation 29. Note that the differentiation would not \ have worked if the parameters had been assigned values.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["-D[g,m]/D[g,lambda]/.params"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Find the sensitivity of ", Evaluatable->False, AspectRatioFixed->True], StyleBox["\[Lambda]", Evaluatable->False, AspectRatioFixed->True], StyleBox[" to changes in l and p in the same way.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True]}, Open]]}, Open]]}, Open]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 640}, {0, 460}}, WindowToolbars->{}, CellGrouping->Manual, WindowSize->{520, 365}, WindowMargins->{{4, Automatic}, {Automatic, 1}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, MacintoshSystemPageSetup->"\<\ AVU/IFiQKFD000000V:^/09R]g0000000OVaH097bCP0AP1Y06`0I@1^0642HZj` 0V:gT0000001nK500TO9>000000000000000009R[[0000000000000000000000 00000000000000000000000000000000\>" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 86, 2, 70, "Section", Evaluatable->False], Cell[CellGroupData[{ Cell[1840, 55, 81, 2, 70, "Subsection", Evaluatable->False], Cell[CellGroupData[{ Cell[1944, 59, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[2032, 63, 99, 2, 70, "Text", Evaluatable->False], Cell[2134, 67, 72, 1, 70, "Input"], Cell[2209, 70, 177, 4, 70, "Input"], Cell[2389, 76, 65, 1, 70, "Input"], Cell[2457, 79, 101, 2, 70, "Text", Evaluatable->False], Cell[2561, 83, 108, 2, 70, "Input"], Cell[2672, 87, 150, 4, 70, "Text", Evaluatable->False], Cell[2825, 93, 89, 1, 70, "Input"], Cell[2917, 96, 82, 1, 70, "Input"], Cell[3002, 99, 126, 2, 70, "Text", Evaluatable->False], Cell[3131, 103, 91, 1, 70, "Input"], Cell[3225, 106, 72, 1, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[3329, 109, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[3417, 113, 169, 4, 70, "Text", Evaluatable->False], Cell[3589, 119, 80, 1, 70, "Input"], Cell[3672, 122, 57, 1, 70, "Input"], Cell[3732, 125, 62, 1, 70, "Input"], Cell[3797, 128, 172, 4, 70, "Text", Evaluatable->False], Cell[3972, 134, 95, 1, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[4099, 137, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[4187, 141, 155, 4, 70, "Text", Evaluatable->False], Cell[4345, 147, 93, 1, 70, "Input"], Cell[4441, 150, 58, 1, 70, "Input"], Cell[4502, 153, 85, 1, 70, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[4628, 156, 81, 2, 70, "Subsection", Evaluatable->False], Cell[CellGroupData[{ Cell[4732, 160, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[4820, 164, 697, 25, 70, "Text", Evaluatable->False], Cell[5520, 191, 133, 3, 70, "Input"], Cell[5656, 196, 92, 1, 70, "Input"], Cell[5751, 199, 101, 1, 70, "Input"], Cell[5855, 202, 576, 19, 70, "Text", Evaluatable->False], Cell[6434, 223, 84, 1, 70, "Input"], Cell[6521, 226, 86, 1, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[6639, 229, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[6727, 233, 87, 1, 70, "Input"], Cell[6817, 236, 74, 1, 70, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[6932, 239, 81, 2, 70, "Subsection", Evaluatable->False], Cell[7016, 243, 236, 5, 70, "Text", Evaluatable->False], Cell[7255, 250, 76, 1, 70, "Input"], Cell[7334, 253, 80, 1, 70, "Input"], Cell[7417, 256, 61, 1, 70, "Input"], Cell[7481, 259, 59, 1, 70, "Input"], Cell[7543, 262, 89, 1, 70, "Input"], Cell[7635, 265, 93, 1, 70, "Input"], Cell[7731, 268, 298, 6, 70, "Text", Evaluatable->False], Cell[8032, 276, 61, 1, 70, "Input"], Cell[8096, 279, 101, 1, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[8229, 282, 81, 2, 70, "Subsection", Evaluatable->False], Cell[8313, 286, 88, 2, 70, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[8433, 290, 81, 2, 70, "Subsection", Evaluatable->False], Cell[8517, 294, 91, 1, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[8640, 297, 81, 2, 70, "Subsection", Evaluatable->False], Cell[CellGroupData[{ Cell[8744, 301, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[8832, 305, 757, 27, 70, "Text", Evaluatable->False], Cell[9592, 334, 104, 1, 70, "Input"], Cell[9699, 337, 86, 1, 70, "Input"], Cell[9788, 340, 127, 2, 70, "Text", Evaluatable->False], Cell[9918, 344, 110, 2, 70, "Input"], Cell[10031, 348, 86, 1, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[10149, 351, 85, 2, 70, "Subsubsection", Evaluatable->False], Cell[10237, 355, 176, 4, 70, "Text", Evaluatable->False], Cell[10416, 361, 65, 1, 70, "Input"], Cell[10484, 364, 84, 1, 70, "Input"], Cell[10571, 367, 100, 1, 70, "Input"], Cell[10674, 370, 446, 14, 70, "Text", Evaluatable->False], Cell[11123, 386, 80, 1, 70, "Input"], Cell[11206, 389, 350, 12, 70, "Text", Evaluatable->False] }, Closed]] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)