(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 8.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 11125, 374] NotebookOptionsPosition[ 8438, 280] NotebookOutlinePosition[ 9460, 315] CellTagsIndexPosition[ 9383, 310] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[TextData[StyleBox["\[OpenCurlyDoubleQuote]DampedOscDiffEq\ \[CloseCurlyDoubleQuote] Sample Notebook", "Title"]], "Section", CellChangeTimes->{{3.523020851379966*^9, 3.523020861577718*^9}, { 3.5252135539567223`*^9, 3.525213554131114*^9}, {3.525213592853923*^9, 3.525213595955573*^9}, {3.5263090902292337`*^9, 3.526309091582081*^9}, { 3.526309124992982*^9, 3.52630914401475*^9}, {3.5263114013628063`*^9, 3.526311404919738*^9}, {3.5538795271731863`*^9, 3.553879540247909*^9}}], Cell[CellGroupData[{ Cell[TextData[{ "This class is about solving differential equations in ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Section", CellChangeTimes->{{3.5263126073521137`*^9, 3.526312649957903*^9}}], Cell[CellGroupData[{ Cell["\<\ We will only deal with analytic solutions today. Numerical solutions some \ other time.\ \>", "Subsection", CellChangeTimes->{{3.526312668905446*^9, 3.5263126842318287`*^9}}], Cell[BoxData[ RowBox[{"Remove", "[", "\"\\"", "]"}]], "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["", "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell["Analytic solution of a differential equation", "Subsection", CellChangeTimes->{{3.526311538621633*^9, 3.5263115451232777`*^9}}], Cell[CellGroupData[{ Cell["\<\ There are different styles you can use, depending on your taste I guess.\ \>", "Subsubsection", CellChangeTimes->{{3.526312978290358*^9, 3.526312997072209*^9}}], Cell[BoxData[ RowBox[{"DSolve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "'"}], "[", "x", "]"}], "-", RowBox[{"\[Lambda]", " ", RowBox[{"f", "[", "x", "]"}]}]}], "\[Equal]", "0"}], ",", "f", ",", "x"}], "]"}]], "Input", CellChangeTimes->{{3.526311548398209*^9, 3.526311613607922*^9}}], Cell[BoxData[ RowBox[{"DSolve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "'"}], "[", "x", "]"}], "-", RowBox[{"\[Lambda]", " ", RowBox[{"f", "[", "x", "]"}]}]}], "\[Equal]", "0"}], ",", RowBox[{"f", "[", "x", "]"}], ",", "x"}], "]"}]], "Input", CellChangeTimes->{{3.526311644128976*^9, 3.5263116448084993`*^9}}] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["", "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell["Add initial conditions", "Subsection", CellChangeTimes->{{3.526311713319175*^9, 3.526311716679275*^9}}], Cell[BoxData[ RowBox[{"DSolve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "'"}], "[", "x", "]"}], "-", RowBox[{"\[Lambda]", " ", RowBox[{"f", "[", "x", "]"}]}]}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"f", "[", "0", "]"}], "\[Equal]", "A"}]}], "}"}], ",", RowBox[{"f", "[", "x", "]"}], ",", "x"}], "]"}]], "Input", CellChangeTimes->{{3.5263117315011387`*^9, 3.526311745323208*^9}}], Cell[CellGroupData[{ Cell["\<\ Try a second order equation, falling from a height h\ \>", "Subsubsection", CellChangeTimes->{{3.526313020842372*^9, 3.526313030776608*^9}}], Cell[BoxData[ RowBox[{"DSolve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"y", "''"}], "[", "t", "]"}], "==", RowBox[{"-", "g"}]}], ",", RowBox[{ RowBox[{"y", "[", "0", "]"}], "\[Equal]", "h"}], ",", RowBox[{ RowBox[{ RowBox[{"y", "'"}], "[", "0", "]"}], "\[Equal]", "0"}]}], "}"}], ",", RowBox[{"y", "[", "t", "]"}], ",", "t"}], "]"}]], "Input", CellChangeTimes->{{3.526311771336028*^9, 3.5263118255498667`*^9}}] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["", "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell["A physics problem: Falling with linear drag", "Subsection", CellChangeTimes->{{3.526311854012889*^9, 3.526311865314928*^9}}], Cell[BoxData[ RowBox[{"sol", "=", RowBox[{"DSolve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"y", "''"}], "[", "t", "]"}], "+", RowBox[{"b", " ", RowBox[{ RowBox[{"y", "'"}], "[", "t", "]"}]}]}], "==", RowBox[{"-", "g"}]}], ",", RowBox[{ RowBox[{"y", "[", "0", "]"}], "\[Equal]", "h"}], ",", RowBox[{ RowBox[{ RowBox[{"y", "'"}], "[", "0", "]"}], "\[Equal]", "0"}]}], "}"}], ",", RowBox[{"y", "[", "t", "]"}], ",", "t"}], "]"}]}]], "Input", CellChangeTimes->{{3.526311890872691*^9, 3.52631189273497*^9}, { 3.526311930755329*^9, 3.526311942689455*^9}}], Cell[CellGroupData[{ Cell["\<\ My taste is to reduce functions to expressions before working with them\ \>", "Subsubsection", CellChangeTimes->{{3.526313073668154*^9, 3.5263130864113903`*^9}}], Cell[BoxData[ RowBox[{"yFunc", "=", RowBox[{ RowBox[{"y", "[", "t", "]"}], "/.", "sol"}]}]], "Input", CellChangeTimes->{{3.5263096359050293`*^9, 3.526309676236763*^9}, { 3.526309706342243*^9, 3.526309709326475*^9}, {3.526311980934149*^9, 3.526311995416806*^9}}], Cell[BoxData[ RowBox[{"Simplify", "[", "yFunc", "]"}]], "Input", CellChangeTimes->{{3.526312851230557*^9, 3.526312856125598*^9}}] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["", "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell["Set some parameters and plot it", "Subsection", CellChangeTimes->{{3.526312153203257*^9, 3.526312159402108*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"yPlot", "=", RowBox[{"yFunc", "/.", RowBox[{"{", RowBox[{ RowBox[{"g", "\[Rule]", "9.8"}], ",", RowBox[{"h", "\[Rule]", " ", "100"}]}], "}"}]}]}], ";"}]], "Input", CellChangeTimes->{{3.526309714349605*^9, 3.526309789771308*^9}, { 3.52630986436762*^9, 3.5263098696834917`*^9}, {3.526310191956388*^9, 3.52631019205891*^9}, {3.5263102838615427`*^9, 3.526310284525442*^9}, { 3.5263110901871157`*^9, 3.526311098633507*^9}, {3.5263111787334414`*^9, 3.526311192564732*^9}, {3.526312017337536*^9, 3.5263120744749317`*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"yPlot", "/.", RowBox[{"{", RowBox[{"b", "\[Rule]", "2"}], "}"}]}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "6"}], "}"}], ",", RowBox[{"PlotRange", "\[Rule]", "Full"}]}], "]"}]], "Input", CellChangeTimes->{{3.525244365518943*^9, 3.525244403345203*^9}, 3.5252444902466908`*^9, {3.5263098923351917`*^9, 3.526309902931851*^9}, { 3.526311211015671*^9, 3.526311213805044*^9}, {3.526312079695043*^9, 3.526312090859765*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["", "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell["Manipulate the drag coefficient", "Subsection", CellChangeTimes->{{3.526312177666997*^9, 3.526312182770784*^9}}], Cell[BoxData[ RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"yPlot", "/.", RowBox[{"{", RowBox[{"b", "\[Rule]", "a"}], "}"}]}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "20"}], "}"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "100"}], "}"}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"a", ",", "0.001", ",", "10"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.525245245487266*^9, 3.525245316386396*^9}, { 3.5252736270220222`*^9, 3.525273735317795*^9}, {3.5263099417206984`*^9, 3.526309992111774*^9}, {3.5263102232532597`*^9, 3.526310223429388*^9}, { 3.526310636577059*^9, 3.526310637096738*^9}, {3.5263112290052633`*^9, 3.52631125070205*^9}, {3.5263121919278193`*^9, 3.526312208135109*^9}, { 3.52631225075988*^9, 3.526312259879962*^9}, {3.526312299817329*^9, 3.526312325804171*^9}}] }, Open ]] }, Open ]] }, ScreenStyleEnvironment->"Working", WindowSize->{957, 770}, WindowMargins->{{46, Automatic}, {Automatic, 19}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrintingOptions->{"PaperOrientation"->"Landscape", "PaperSize"->{787.56, 603.}}, FrontEndVersion->"8.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (November 6, \ 2010)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "SlideShowHeader"->{ Cell[1618, 53, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[2805, 97, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[4243, 150, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[5850, 206, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[7219, 246, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"]} } *) (*CellTagsIndex CellTagsIndex->{ {"SlideShowHeader", 8921, 296} } *) (*NotebookFileOutline Notebook[{ Cell[557, 20, 489, 6, 83, "Section"], Cell[CellGroupData[{ Cell[1071, 30, 211, 6, 37, "Section"], Cell[CellGroupData[{ Cell[1307, 40, 185, 4, 34, "Subsection"], Cell[1495, 46, 74, 1, 27, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[1618, 53, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell[1707, 58, 134, 1, 34, "Subsection"], Cell[CellGroupData[{ Cell[1866, 63, 171, 3, 24, "Subsubsection"], Cell[2040, 68, 337, 10, 27, "Input"], Cell[2380, 80, 364, 10, 27, "Input"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[2805, 97, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell[2894, 102, 110, 1, 34, "Subsection"], Cell[3007, 105, 490, 14, 27, "Input"], Cell[CellGroupData[{ Cell[3522, 123, 151, 3, 24, "Subsubsection"], Cell[3676, 128, 506, 15, 27, "Input"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[4243, 150, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell[4332, 155, 131, 1, 34, "Subsection"], Cell[4466, 158, 715, 22, 27, "Input"], Cell[CellGroupData[{ Cell[5206, 184, 172, 3, 24, "Subsubsection"], Cell[5381, 189, 274, 6, 27, "Input"], Cell[5658, 197, 131, 2, 27, "Input"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[5850, 206, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell[5939, 211, 119, 1, 34, "Subsection"], Cell[6061, 214, 588, 12, 27, "Input"], Cell[6652, 228, 518, 12, 27, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[7219, 246, 64, 1, 63, "SlideShowNavigationBar", CellTags->"SlideShowHeader"], Cell[CellGroupData[{ Cell[7308, 251, 119, 1, 34, "Subsection"], Cell[7430, 254, 980, 22, 58, "Input"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)