(*^ ::[ frontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.1"; macintoshStandardFontEncoding; paletteColors = 128; automaticGrouping; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; ; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier"; ; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva"; ; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = leftheader, inactive, L2, 12, "Times"; ; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times"; ; fontset = leftfooter, inactive, L2, 12, "Times"; ; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; ; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; ] :[font = special1; inactive; preserveAspect; ] Predators and Prey -- Springs and Masses The cell below illustrates how Mathematica can be used to study models like the Predator - Prey model in this section. Evaluate it now. Then use it as a basis for further investigation of both predator-prey models and spring-and-mass models. The Mathematica procedure NDSolve used in this cell to find numerical approximations for a solution to a system of differential equations is very sophisticated and is more accurate than the procedure used by the applets or by the TI-92 programs in this module. For this reason it is difficult to see the errors that do occur -- they are just too small. Nonetheless these errors would accumulate over a long period of time and they do make it impossible to predict the long term behavior of these kinds of models with complete certainty. Because we want to investigate the effects of the errors inherent in numerical procedures, the cell after the cell below uses a cruder method -- Euler's method -- in which the numerical errors are more evident. ;[s] 12:0,1;68,0;101,2;112,0;191,3;314,0;317,4;321,5;332,4;345,6;352,4;860,7;1071,-1; 8:3,13,9,Times,0,12,0,0,0;1,13,9,Times,1,12,0,0,0;1,13,9,Times,2,12,0,0,0;1,13,9,Times,1,12,65535,0,0;3,13,9,Times,0,12,0,0,65535;1,13,9,Times,2,12,0,0,65535;1,13,9,Times,1,12,0,0,65535;1,13,9,Times,1,12,65535,0,65535; :[font = input; preserveAspect; ] Clear[solution] thigh := 10 solution = NDSolve[ {p'[t] == (0.005 q[t] - 1) p[t], q'[t] == (1 - 0.005 p[t]) q[t], p[0] == 300.0, q[0] == 300.0}, {p[t], q[t]}, {t, 0, thigh}]; Plot[{p[t] /. solution, q[t] /. solution}, {t,0, thigh}, PlotStyle -> {{RGBColor[1, 0, 0]},{RGBColor[0, 0, 1]}}] ParametricPlot[{p[t], q[t]} /. solution, {t, 0, thigh}, PlotRange -> {{0, 400}, {0, 400}}, AspectRatio -> Automatic] :[font = input; preserveAspect; ] Clear[p, q, h, f, g, graph1, graph2, plot1, plot2, graph] p[0] := 300 q[0] := 300 h := 0.1 steps := 120 f[p_, q_] := (0.005 q - 1) p g[p_, q_] := (1 - 0.005 p) q p[n_] := p[n] = p[n - 1] + h f[p[n - 1], q[n - 1]] q[n_] := q[n] = q[n - 1] + h g[p[n - 1], q[n - 1]] graph1 = Table[{n, p[n]}, {n, 0, steps}]; graph2 = Table[{n, q[n]}, {n, 0, steps}]; graph = Table[{p[n], q[n]}, {n, 0, steps}]; plot1 = ListPlot[graph1, PlotJoined -> True, PlotStyle -> {RGBColor[1, 0, 0]}, DisplayFunction -> Identity] plot2 = ListPlot[graph2, PlotJoined -> True, PlotStyle -> {RGBColor[0, 0, 1]}, DisplayFunction -> Identity] Show[{plot1, plot2}, DisplayFunction -> $DisplayFunction] ListPlot[graph, PlotRange -> {{0, 500}, {0, 500}}, AspectRatio -> Automatic, PlotJoined -> True] ^*)