(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 27358, 965] NotebookOptionsPosition[ 23919, 857] NotebookOutlinePosition[ 24332, 875] CellTagsIndexPosition[ 24289, 872] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Understanding NDSolve", "Title"], Cell["\<\ AP1601 Columbia University\ \>", "Subsubtitle"], Cell[CellGroupData[{ Cell["Connecting the Dots", "Section"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " can easily make lists of numbers." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"sineList", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"Sin", "[", "x", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", "0", ",", " ", RowBox[{"6", " ", "\[Pi]"}], ",", " ", RowBox[{"6", " ", RowBox[{"\[Pi]", "/", "100"}]}]}], "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[1]:="], Cell[BoxData[ RowBox[{"p1", "=", RowBox[{"ListPlot", "[", RowBox[{"sineList", ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"PointSize", "[", "0.02`", "]"}]}]}], "]"}]}]], "Input", CellLabel->"In[2]:="], Cell[TextData[{ "While a list of numbers can be plotted and displayed, it is not a function \ until we tell ", StyleBox["Mathematica", FontSlant->"Italic"], " how to connect the dots." }], "Text"], Cell[BoxData[ RowBox[{"?", "Interpolation"}]], "Input", CellLabel->"In[3]:="], Cell[BoxData[ RowBox[{"?", "InterpolatingFunction"}]], "Input", CellLabel->"In[4]:="], Cell[BoxData[ RowBox[{"s", "=", " ", RowBox[{"Interpolation", "[", RowBox[{"sineList", " ", "//", "N"}], "]"}]}]], "Input", CellLabel->"In[5]:="], Cell[TextData[{ "The \"standard form\" of displaying an ", StyleBox["InterpolatingFunction[...]", FontWeight->"Bold"], " suppresses the long list of numbers used to create the interpolation. We \ can see the hidden information by using ", StyleBox["FullForm[...]", FontWeight->"Bold"], ":" }], "Text"], Cell[BoxData[ RowBox[{"s", " ", "//", " ", "FullForm"}]], "Input", CellLabel->"In[6]:="], Cell[TextData[{ "We must use ", StyleBox["ListPlot[...]", FontWeight->"Bold"], " to display a list of numbers. For functions, we must use ", StyleBox["Plot[...].", FontWeight->"Bold"] }], "Text"], Cell[BoxData[ RowBox[{"p2", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"s", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"6", " ", "\[Pi]"}]}], "}"}]}], "]"}]}]], "Input", CellLabel->"In[7]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p1", ",", "p2"}], "]"}]], "Input", CellLabel->"In[8]:="], Cell[TextData[{ "If you look carefully, the interpolation is slightly curved.\nBy default, \ ", StyleBox["Interpolation[...]", FontWeight->"Bold"], " connects the dots with third order polynomials." }], "Text"], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p1", ",", "p2", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4.`", ",", "5.5`"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.`"}], ",", RowBox[{"-", "0.6`"}]}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[9]:="], Cell["\<\ We can examine the error between the true function and the interpolation\ \[Ellipsis]\ \>", "Text"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"s", "[", "x", "]"}], "-", RowBox[{"Sin", "[", "x", "]"}]}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"3", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"PlotPoints", "\[Rule]", "200"}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[10]:="] }, Closed]], Cell[CellGroupData[{ Cell["Connecting Fewer Dots", "Section"], Cell["\<\ When there are fewer points, we also have less information to represent the \ function.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"sineList2", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", " ", RowBox[{"Sin", "[", "x", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", "0", ",", " ", RowBox[{"6", " ", "\[Pi]"}], ",", " ", RowBox[{"6", " ", RowBox[{"\[Pi]", "/", "25"}]}]}], "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[11]:="], Cell[BoxData[ RowBox[{ RowBox[{"blue", " ", "=", " ", RowBox[{"RGBColor", "[", RowBox[{"0", ",", "0", ",", "1"}], "]"}]}], ";"}]], "Input", CellLabel->"In[12]:="], Cell[BoxData[ RowBox[{"p3", "=", RowBox[{"ListPlot", "[", RowBox[{"sineList2", ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "0.02`", "]"}], ",", "blue"}], "}"}]}]}], "]"}]}]], "Input", CellLabel->"In[13]:="], Cell[BoxData[ RowBox[{"s2", "=", " ", RowBox[{"Interpolation", "[", RowBox[{"sineList2", " ", "//", "N"}], "]"}]}]], "Input", CellLabel->"In[14]:="], Cell[BoxData[ RowBox[{"p4", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"s2", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"6", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "blue", "}"}]}]}], "]"}]}]], "Input", CellLabel->"In[15]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p3", ",", "p4"}], "]"}]], "Input", CellLabel->"In[16]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p3", ",", "p4", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4.`", ",", "5.5`"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.`"}], ",", RowBox[{"-", "0.6`"}]}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[17]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p1", ",", "p2", ",", "p3", ",", "p4", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4.`", ",", "5.5`"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.`"}], ",", RowBox[{"-", "0.6`"}]}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[18]:="], Cell[CellGroupData[{ Cell["Reducing the Interpolation Order", "Subsection"], Cell["\<\ If we lower the order of the polynomial used to construct the interpolation, \ then \"smoothness\" of the interpolation is reduced.\ \>", "Text"], Cell[BoxData[ RowBox[{"s2", "=", " ", RowBox[{"Interpolation", "[", RowBox[{ RowBox[{"sineList2", " ", "//", "N"}], ",", RowBox[{"InterpolationOrder", " ", "\[Rule]", " ", "2"}]}], "]"}]}]], "Input", CellLabel->"In[19]:="], Cell[BoxData[ RowBox[{"p4", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"s2", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"6", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "blue", "}"}]}]}], "]"}]}]], "Input", CellLabel->"In[20]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p1", ",", "p2", ",", "p3", ",", "p4", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4.`", ",", "5.5`"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.`"}], ",", RowBox[{"-", "0.6`"}]}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[21]:="] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["InterpolatingFunctions are \"Pretty Good\" Functions", "Section"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " treats interpolating functions as real functions. What I mean by this \ phrase is that ", StyleBox["Mathematica", FontSlant->"Italic"], " can integrate and differentiate interpolatingfunctions in the same way \ that it differentiates and integrates other functions." }], "Text"], Cell["Taking the derivative, returns:", "Text"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"Sin", "[", "x", "]"}], ",", "x"}], "]"}], ",", " ", RowBox[{"D", "[", RowBox[{ RowBox[{"s", "[", "x", "]"}], ",", "x"}], "]"}]}], "}"}]], "Input", CellLabel->"In[22]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{ SubscriptBox["\[PartialD]", "x"], RowBox[{"Sin", "[", "x", "]"}]}], ",", RowBox[{ SubscriptBox["\[PartialD]", "x"], RowBox[{"s", "[", "x", "]"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"6", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[23]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"%", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2.5`", ",", "4.`"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.`"}], ",", RowBox[{"-", "0.6`"}]}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[24]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{ SubscriptBox["\[PartialD]", RowBox[{"{", RowBox[{"x", ",", "2"}], "}"}]], RowBox[{"Sin", "[", "x", "]"}]}], ",", RowBox[{ SubscriptBox["\[PartialD]", RowBox[{"{", RowBox[{"x", ",", "2"}], "}"}]], RowBox[{"s", "[", "x", "]"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"6", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[25]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"%", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4.`", ",", "5.5`"}], "}"}], ",", RowBox[{"{", RowBox[{"0.6`", ",", "1.`"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[26]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{ SubscriptBox["\[PartialD]", RowBox[{"{", RowBox[{"x", ",", "3"}], "}"}]], RowBox[{"Sin", "[", "x", "]"}]}], ",", RowBox[{ SubscriptBox["\[PartialD]", RowBox[{"{", RowBox[{"x", ",", "3"}], "}"}]], RowBox[{"s", "[", "x", "]"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"6", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[27]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"%", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2.5`", ",", "4.`"}], "}"}], ",", RowBox[{"{", RowBox[{"0.6`", ",", "1.`"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[28]:="] }, Closed]], Cell[CellGroupData[{ Cell["You can control NDSolve", "Section"], Cell[TextData[{ StyleBox["NDSolve", FontWeight->"Bold"], " is a powerful command with many options that you can control. Most of \ these control the number of points used to represent your solution and the \ accuracy of your solution. More accurate solutions require more points. So do \ solutions having a longer range. Of course, your computer requires more \ memory and more time to represent more accurate solutions defined on longer \ time ranges." }], "Text"], Cell[CellGroupData[{ Cell["Equations for an Ellipse", "Subsection"], Cell[BoxData[ RowBox[{"eqel", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", "t"}], "]"}], " ", "\[Equal]", " ", RowBox[{"y", "[", "t", "]"}]}], ",", " ", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"y", "[", "t", "]"}], ",", "t"}], "]"}], " ", "\[Equal]", " ", RowBox[{ RowBox[{"-", " ", "b"}], " ", RowBox[{"x", "[", "t", "]"}]}]}]}], "}"}]}]], "Input", CellLabel->"In[29]:="], Cell[BoxData[ RowBox[{"initial", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"x", "[", "0", "]"}], " ", "\[Equal]", " ", "x0"}], ",", " ", RowBox[{ RowBox[{"y", "[", "0", "]"}], " ", "\[Equal]", " ", "y0"}]}], "}"}]}]], "Input", CellLabel->"In[30]:="], Cell[BoxData[ RowBox[{"eqs", " ", "=", " ", RowBox[{ "eqel", " ", "~", " ", "Join", " ", "~", " ", "initial"}]}]], "Input", CellLabel->"In[31]:="], Cell[BoxData[ RowBox[{"sol1", " ", "=", " ", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"eqs", " ", "/.", " ", RowBox[{"x0", " ", "\[Rule]", " ", "1"}]}], " ", "/.", " ", RowBox[{"y0", " ", "\[Rule]", " ", "0"}]}], " ", "/.", " ", RowBox[{"b", "\[Rule]", " ", "2"}]}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", " ", RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", "0", ",", " ", "10"}], "}"}]}], "]"}]}]], "Input",\ CellLabel->"In[32]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[InvisibleSpace]", "sol1"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "10"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[33]:="], Cell[BoxData[ RowBox[{"ParametricPlot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[InvisibleSpace]", "sol1"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "10"}], "}"}]}], "]"}]], "Input", CellLabel->"In[34]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"%", ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]], "Input", CellLabel->"In[35]:="], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"x", "[", "t", "]"}], " ", "/.", " ", "sol1"}], " ", "//", " ", "FullForm"}]], "Input", CellLabel->"In[36]:="] }, Closed]], Cell[CellGroupData[{ Cell["Options to NDSolve", "Subsection"], Cell[BoxData[ RowBox[{"??", "NDSolve"}]], "Input", CellLabel->"In[37]:="], Cell[BoxData[ RowBox[{"sol1", " ", "=", " ", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"eqs", " ", "/.", " ", RowBox[{"x0", " ", "\[Rule]", " ", "1"}]}], " ", "/.", " ", RowBox[{"y0", " ", "\[Rule]", " ", "0"}]}], " ", "/.", " ", RowBox[{"b", "\[Rule]", " ", "2"}]}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", " ", RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", "0", ",", " ", "1000"}], "}"}]}], "]"}]}]], "Input", CellLabel->"In[38]:="], Cell[BoxData[ RowBox[{"sol1", " ", "=", " ", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"eqs", " ", "/.", " ", RowBox[{"x0", " ", "\[Rule]", " ", "1"}]}], " ", "/.", " ", RowBox[{"y0", " ", "\[Rule]", " ", "0"}]}], " ", "/.", " ", RowBox[{"b", "\[Rule]", " ", "2"}]}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", " ", RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", "0", ",", " ", "1000"}], "}"}], ",", " ", RowBox[{"MaxSteps", " ", "\[Rule]", " ", "15000"}]}], "]"}]}]], "Input", CellLabel->"In[39]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[InvisibleSpace]", "sol1"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "500"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[40]:="], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"%", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"100", ",", "120"}], "}"}], ",", "All"}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[41]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[InvisibleSpace]", "sol1"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "100", ",", "120"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[42]:="], Cell[BoxData[ RowBox[{"sol2", " ", "=", " ", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"eqs", " ", "/.", " ", RowBox[{"x0", " ", "\[Rule]", " ", "1"}]}], " ", "/.", " ", RowBox[{"y0", " ", "\[Rule]", " ", "0"}]}], " ", "/.", " ", RowBox[{"b", "\[Rule]", " ", "2"}]}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", " ", RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", "0", ",", " ", "1000"}], "}"}], ",", " ", RowBox[{"PrecisionGoal", "\[Rule]", " ", "3"}], ",", " ", RowBox[{"AccuracyGoal", "\[Rule]", "3"}]}], "]"}]}]], "Input", CellLabel->"In[43]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol1"}], ")"}], "-", RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol2"}], ")"}]}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "500"}], "}"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[44]:="], Cell[BoxData[ RowBox[{"ParametricPlot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[InvisibleSpace]", "sol1"}], ",", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], "/.", "\[InvisibleSpace]", "sol2"}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "500"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"Compiled", "\[Rule]", "False"}]}], "]"}]], "Input", CellLabel->"In[45]:="] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["You can calculate with solutions to NDSolve", "Section"], Cell["\<\ Remember, for most calculations that you want to perform with your solutions \ to the equations of motion, you can treat the solutions from NDSolve just \ like any other \"real\" function.\ \>", "Text"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol1"}], ",", RowBox[{ SubscriptBox["\[PartialD]", "t"], RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol1"}], ")"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "50"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[46]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"y", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol1"}], ",", RowBox[{ SubscriptBox["\[PartialD]", "t"], RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol1"}], ")"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "50"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[47]:="], Cell[BoxData[ RowBox[{ RowBox[{"radius", "[", "t_", "]"}], " ", "=", " ", RowBox[{ RowBox[{"Sqrt", "[", RowBox[{ RowBox[{ RowBox[{"x", "[", "t", "]"}], "^", "2"}], " ", "+", " ", RowBox[{ RowBox[{"y", "[", "t", "]"}], "^", "2"}]}], "]"}], " ", "/.", " ", "sol1"}]}]], "Input", CellLabel->"In[48]:="], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"{", RowBox[{ RowBox[{"radius", "[", "t", "]"}], ",", RowBox[{ SubscriptBox["\[PartialD]", "t"], RowBox[{"radius", "[", "t", "]"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "50"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", "blue", "}"}]}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[49]:="] }, Closed]], Cell[CellGroupData[{ Cell["Summary", "Section"], Cell[TextData[{ StyleBox["NDSolve[\[Ellipsis]]", FontWeight->"Bold"], " is a powerful built-in function in ", StyleBox["Mathematica", FontSlant->"Italic"], " for solving differential equations. The solutions returned by ", StyleBox["NDSolve[\[Ellipsis]]", FontWeight->"Bold"], " are interpolating functions. Interpolating functions are \"real \ functions\". They can be combined in complex expressions, integrated and \ differentiated. ", StyleBox["However,", FontSlant->"Italic"], " they are only approximations to the actual solution to the differential \ equations. These approximations generally have increasing error for long-time \ integrations." }], "Text"] }, Closed]] }, Open ]] }, WindowSize->{648, 791}, WindowMargins->{{0, Automatic}, {Automatic, 1}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, ShowSelection->True, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (May 21, 2008)", StyleDefinitions->"TutorialBook.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 38, 0, 51, "Title"], Cell[631, 25, 57, 3, 41, "Subsubtitle"], Cell[CellGroupData[{ Cell[713, 32, 38, 0, 86, "Section"], Cell[754, 34, 114, 4, 23, "Text"], Cell[871, 40, 446, 13, 26, "Input"], Cell[1320, 55, 221, 6, 26, "Input"], Cell[1544, 63, 201, 6, 41, "Text"], Cell[1748, 71, 79, 2, 26, "Input"], Cell[1830, 75, 87, 2, 26, "Input"], Cell[1920, 79, 154, 4, 26, "Input"], Cell[2077, 85, 310, 9, 41, "Text"], Cell[2390, 96, 90, 2, 26, "Input"], Cell[2483, 100, 203, 7, 23, "Text"], Cell[2689, 109, 250, 8, 24, "Input"], Cell[2942, 119, 105, 3, 24, "Input"], Cell[3050, 124, 215, 6, 53, "Text"], Cell[3268, 132, 435, 13, 44, "Input"], Cell[3706, 147, 110, 3, 24, "Text"], Cell[3819, 152, 407, 12, 45, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[4263, 169, 40, 0, 54, "Section"], Cell[4306, 171, 111, 3, 23, "Text"], Cell[4420, 176, 447, 13, 26, "Input"], Cell[4870, 191, 175, 5, 24, "Input"], Cell[5048, 198, 285, 9, 45, "Input"], Cell[5336, 209, 157, 4, 26, "Input"], Cell[5496, 215, 330, 10, 24, "Input"], Cell[5829, 227, 106, 3, 24, "Input"], Cell[5938, 232, 436, 13, 44, "Input"], Cell[6377, 247, 458, 13, 60, "Input"], Cell[CellGroupData[{ Cell[6860, 264, 54, 0, 34, "Subsection"], Cell[6917, 266, 155, 3, 41, "Text"], Cell[7075, 271, 244, 7, 45, "Input"], Cell[7322, 280, 330, 10, 24, "Input"], Cell[7655, 292, 458, 13, 60, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[8162, 311, 71, 0, 54, "Section"], Cell[8236, 313, 350, 9, 59, "Text"], Cell[8589, 324, 47, 0, 23, "Text"], Cell[8639, 326, 273, 9, 26, "Input"], Cell[8915, 337, 617, 20, 44, "Input"], Cell[9535, 359, 424, 13, 44, "Input"], Cell[9962, 374, 735, 24, 46, "Input"], Cell[10700, 400, 376, 11, 44, "Input"], Cell[11079, 413, 735, 24, 46, "Input"], Cell[11817, 439, 376, 11, 44, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[12230, 455, 42, 0, 54, "Section"], Cell[12275, 457, 469, 9, 77, "Text"], Cell[CellGroupData[{ Cell[12769, 470, 46, 0, 34, "Subsection"], Cell[12818, 472, 532, 18, 24, "Input"], Cell[13353, 492, 293, 9, 26, "Input"], Cell[13649, 503, 153, 4, 26, "Input"], Cell[13805, 509, 597, 17, 44, "Input"], Cell[14405, 528, 526, 17, 44, "Input"], Cell[14934, 547, 385, 12, 44, "Input"], Cell[15322, 561, 152, 4, 26, "Input"], Cell[15477, 567, 160, 5, 26, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[15674, 577, 40, 0, 34, "Subsection"], Cell[15717, 579, 75, 2, 24, "Input"], Cell[15795, 583, 601, 17, 44, "Input"], Cell[16399, 602, 664, 17, 44, "Input"], Cell[17066, 621, 527, 17, 44, "Input"], Cell[17596, 640, 257, 9, 24, "Input"], Cell[17856, 651, 529, 17, 44, "Input"], Cell[18388, 670, 717, 18, 62, "Input"], Cell[19108, 690, 565, 18, 62, "Input"], Cell[19676, 710, 896, 27, 80, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[20621, 743, 62, 0, 54, "Section"], Cell[20686, 745, 212, 4, 41, "Text"], Cell[20901, 751, 679, 22, 44, "Input"], Cell[21583, 775, 679, 22, 44, "Input"], Cell[22265, 799, 341, 11, 28, "Input"], Cell[22609, 812, 536, 17, 44, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[23182, 834, 26, 0, 54, "Section"], Cell[23211, 836, 680, 17, 96, "Text"] }, Closed]] }, Open ]] } ] *) (* End of internal cache information *)