(************** Content-type: application/mathematica ************** Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing 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[ 8812, 273]*) (*NotebookOutlinePosition[ 9517, 297]*) (* CellTagsIndexPosition[ 9473, 293]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ StyleBox["The write-up for this lab should be in two parts. \n1. First, \ you can just informally respond to the first You Try It and make observations \ about other questions posed. This can be submitted in pairs.\n2. Second, \ write a ", FontSize->16], StyleBox["formal", FontSize->16, FontWeight->"Bold"], StyleBox[" report for Part 2 of the Lake Pollution Project. This can be \ either a ", FontSize->16], StyleBox["Mathematica ", FontSize->16, FontSlant->"Italic"], StyleBox["document that is in report form", FontSize->16], StyleBox[" ", FontSize->16, FontSlant->"Italic"], StyleBox["or", FontSize->16], StyleBox[" ", FontSize->16, FontSlant->"Italic"], StyleBox["a Word document with appropriate graphs pasted in. Your report \ must begin with an executive summary and have justifications for each \ requirement. This will be a write-up not only about the numerical solution, \ but also about the analytical solution and the role of the eigenvalues and \ corresponding eigenvectors. This also may be submitted in pairs.", FontSize->16] }], "Text"], Cell[CellGroupData[{ Cell["\<\ Demonstration of Numerical and Analytical Solution of Part 1 of the Lake Pollution Project\ \>", "Subtitle", TextAlignment->Center, FontFamily->"Colonna MT", FontSlant->"Italic"], Cell[CellGroupData[{ Cell["Numerical Solution", "Section"], Cell[TextData[{ "Consider the information in the first part of the lake pollution project \ expressed in terms of vectors and matrices. Your system of difference \ equations could be written as ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {\(erie\_\(n = 1\)\)}, {\(ontario\_\(n + 1\)\)} }], ")"}], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {".62", "0"}, {".38", ".87"} }], ")"}], TraditionalForm]]], Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {\(erie\_n\)}, {\(ontario\_n\)} }], ")"}], TraditionalForm]]], "+", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"0"}, {"25"} }], ")"}], TraditionalForm]]], " and the initial states of the lakes could be determined from the \ information given.\nThe code below shows how you could move from one state to \ the next by using a Do-loop. The list called \"lakes\" stores the sets of \ values generated. Make sure you understand each step in the code below. ", StyleBox["See if the pollution concentration levels in the lakes is \ approaching an equilibrium.", FontColor->RGBColor[1, 0, 0]] }], "Text"], Cell[BoxData[{ \(\(m = {{ .62, 0}, { .38, .87}};\)\), "\n", \(\(init = {2500, 2500};\)\), "\n", \(\(lakes = {init};\)\), "\n", \(\(add = {0, 25};\)\), "\n", \(\(new = m . init + add;\)\), "\n", \(\(AppendTo[lakes, new];\)\), "\n", \(Do[{new = m . new + add, AppendTo[lakes, new]}, {100}]\), "\n", \(lakes\)}], "Input", FontSize->14] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["You Try It", FontColor->RGBColor[1, 0, 0]], ": Check Out Long-Term Behavior" }], "Section"], Cell["\<\ Does the long-term behavior depend on the inital state? Change the entries in \ the \"init\" vector and see what happens down the road. What does this say \ about the stability of the equilibrium?\ \>", "Text"], Cell[BoxData[{\(m = {{ .62, 0}, { .38, .87}};\), "\n", RowBox[{ RowBox[{"init", "=", RowBox[{"{", RowBox[{ StyleBox["2500", FontColor->RGBColor[1, 0, 0]], ",", StyleBox["2500", FontColor->RGBColor[1, 0, 0]]}], "}"}]}], ";"}], "\n", \(lakes = {init};\), "\n", \(add = {0, 25};\), "\n", \(new = m . init + add;\), "\n", \(AppendTo[lakes, new];\), "\n", \(Do[{new = m . new + add, AppendTo[lakes, new]}, {100}]\), "\n", "lakes"}], "Input", FontSize->14], Cell["\<\ What happens to the equilibrium when you change the amount of pollutant added \ to the lake each year?\ \>", "Text"], Cell[BoxData[{\(m = {{ .62, 0}, { .38, .87}};\), "\n", \(init = {2500, 2500};\), "\n", \(lakes = {init};\), "\n", RowBox[{ RowBox[{"add", "=", RowBox[{"{", RowBox[{ StyleBox["0", FontColor->RGBColor[1, 0, 0]], ",", StyleBox["25", FontColor->RGBColor[1, 0, 0]]}], "}"}]}], ";"}], "\n", \(new = m . init + add;\), "\n", \(AppendTo[lakes, new];\), "\n", \(Do[{new = m . new + add, AppendTo[lakes, new]}, {100}]\), "\n", "lakes"}], "Input", FontSize->14], Cell["\<\ Let's make some observations about the situation just described. \ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Individual and Phase Plots", "Section"], Cell["\<\ We can look at our results graphically, first with each lake over time, and, \ although it is not particularly meaningful here like it would be in a \ predator-prey model, we could also look at a phase plot {erie,ontario}.\ \>", "Text"], Cell[BoxData[{ \(\(erie = Table[lakes[\([i, 1]\)], {i, 1, 50}];\)\), "\n", \(\(ontario = Table[lakes[\([i, 2]\)], {i, 1, 50}];\)\), "\n", \(\(plerie = ListPlot[erie, PlotStyle \[Rule] PointSize[ .015]];\)\), "\n", \(\(plont = ListPlot[ontario, PlotStyle -> PointSize[ .02]];\)\), "\n", \(\(Show[plerie, plont];\)\), "\n", \(\(ListPlot[lakes, PlotStyle -> PointSize[ .025]];\)\)}], "Input", FontSize->14] }, Closed]], Cell[CellGroupData[{ Cell["Analytical Solution Using Eigenvalues and Eigenvectors ", "Section"], Cell["\<\ We will be deriving this solution in class. For now, just observe it and see \ if you can decipher the Eigensystem command.\ \>", "Text"], Cell[BoxData[{ \(mult = Inverse[IdentityMatrix[2] - m]\), "\n", \(equil = mult . add\), "\n", \(eig = Eigensystem[m]\), "\n", \(const = Solve[init - mult . add == a\ eig[\([2, 1]\)] + \ b\ eig[\([2, 2]\)], {a, b}]\), "\n", \(ansoln = Sum[const[\([1, i, 2]\)] eig[\([1, i]\)]^n\ eig[\([2, i]\)], {i, 1, 2}] + equil\), "\n", \(ansoln /. n -> 100\)}], "Input", FontSize->14] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["You Try It", FontColor->RGBColor[1, 0, 0]], ": Part 2 of the Lake Pollution Project" }], "Section"], Cell[TextData[{ StyleBox["Go through the same steps for the three-lake problem.", FontColor->RGBColor[1, 0, 0]], " Here are some commands to get you started" }], "Text"], Cell[BoxData[{ \(\(m3 = {{ .89, 0, 0}, { .11, .64, 0}, {0, .36, .88}};\)\), "\n", \(\(add3 = {30, 0, 30};\)\), "\n", \(\(init3 = {3500, 1800, 2400};\)\)}], "Input"], Cell[BoxData[{ \(mult3 = Inverse[IdentityMatrix[3] - m3]\), "\n", \(equil3 = mult3 . add3\), "\[IndentingNewLine]", \(eig3 = Eigensystem[m3]\)}], "Input"] }, Closed]] }, Open ]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowSize->{685, 521}, WindowMargins->{{0, Automatic}, {Automatic, 5}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic} ] (******************************************************************* 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[1705, 50, 1142, 31, 198, "Text"], Cell[CellGroupData[{ Cell[2872, 85, 196, 7, 122, "Subtitle"], Cell[CellGroupData[{ Cell[3093, 96, 37, 0, 59, "Section"], Cell[3133, 98, 1330, 37, 140, "Text"], Cell[4466, 137, 374, 9, 170, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[4877, 151, 125, 4, 39, "Section"], Cell[5005, 157, 220, 4, 52, "Text"], Cell[5228, 163, 573, 13, 170, "Input"], Cell[5804, 178, 126, 3, 33, "Text"], Cell[5933, 183, 573, 13, 170, "Input"], Cell[6509, 198, 89, 2, 33, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[6635, 205, 45, 0, 39, "Section"], Cell[6683, 207, 246, 4, 52, "Text"], Cell[6932, 213, 443, 8, 130, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[7412, 226, 74, 0, 39, "Section"], Cell[7489, 228, 147, 3, 33, "Text"], Cell[7639, 233, 440, 11, 130, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[8116, 249, 133, 4, 39, "Section"], Cell[8252, 255, 177, 4, 33, "Text"], Cell[8432, 261, 181, 3, 70, "Input"], Cell[8616, 266, 168, 3, 70, "Input"] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)