(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' 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[ 11790, 386]*) (*NotebookOutlinePosition[ 13020, 423]*) (* CellTagsIndexPosition[ 12976, 419]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Nonlinear Differential Equations: Pendulum", "Subtitle", TextAlignment->Center, TextJustification->0], Cell["\<\ In this notebook, we solve nonlinear differential equations, \ looking at the time dependence, phase space plots, Poincare sections, and the \ power spectrum. The notebook has specialized to a pendulum equation, with parameters used in \ session 9 of 780.20. \ \>", "Text"], Cell[CellGroupData[{ Cell["Define the Differential Equation", "Section"], Cell["\<\ Name the equation \"diffeq\". Note the \"==\" in defining the \ equation. \ \>", "Text"], Cell[BoxData[ \(diffeq\ := \ \(\[Theta]''\)[ t]\ + \ \[Alpha]\ \(\[Theta]'\)[ t]\ + \ \[Omega]0^2\ Sin[\[Theta][t]]\ \[Equal] \ fext\ Cos[\[Omega]ext*t\ + \ \[Phi]ext]\)], "Input", CellLabel->"In[1]:="], Cell["Choose among the parameters:", "Text"], Cell[BoxData[ \(\(p1\ := \ {\[Alpha] = 0. , \[Omega]0 = 1, fext = 0. , \[Omega]ext = 0.689, \[Phi]ext = \ 0.0};\)\)], "Input", CellLabel->"In[2]:="], Cell[BoxData[ \(\(p2\ := \ {\[Alpha] = 0.2, \[Omega]0 = 1, fext = 0.52, \[Omega]ext = 0.689, \[Phi]ext = \ 0.0};\)\)], "Input",\ CellLabel->"In[3]:="], Cell[BoxData[ \(\(p3 := {\[Alpha] = 0.2, \[Omega]0 = 1, fext = 0.52, \[Omega]ext = 0.694, \[Phi]ext = 0.0};\)\)], "Input", CellLabel->"In[4]:="], Cell[BoxData[ \(\(p4 := {\[Alpha] = 0.2, \[Omega]0 = 1, fext = 0.52, \[Omega]ext = 0.689, \[Phi]ext = 0.0};\)\)], "Input", CellLabel->"In[5]:="], Cell[BoxData[ \(\(p5 := {\[Alpha] = 0.2, \[Omega]0 = 1, fext = 0.9, \[Omega]ext = 0.54, \[Phi]ext = 0.0};\)\)], "Input", CellLabel->"In[6]:="], Cell[BoxData[ \(p2\)], "Input", CellLabel->"In[7]:="], Cell["Choose among the initial conditions:", "Text"], Cell[BoxData[ \(\(ic1\ := \ {\[Theta]0 = 0.8, \[Theta]dot0 = 0. };\)\)], "Input", CellLabel->"In[8]:="], Cell[BoxData[ \(\(ic2\ := \ {\[Theta]0\ = \ \(-0.8\), \ \[Theta]dot0\ = \ 0.1234};\)\)], "Input", CellLabel->"In[9]:="], Cell[BoxData[ \(\(ic3 := {\[Theta]0 = 0.8, \[Theta]dot0 = 0.8};\)\)], "Input", CellLabel->"In[10]:="], Cell[BoxData[ \(\(ic4 := {\[Theta]0 = 0.8, \[Theta]dot0 = 0.8};\)\)], "Input", CellLabel->"In[11]:="], Cell[BoxData[ \(\(ic5 := {\[Theta]0 = \(-0.8\), \[Theta]dot0 = 0.1234};\)\)], "Input", CellLabel->"In[12]:="], Cell[BoxData[ \(ic2\)], "Input", CellLabel->"In[13]:="] }, Open ]], Cell[CellGroupData[{ Cell["Solve the Differential Equation", "Section"], Cell["\<\ Specify the range in time over which we will solve the differential \ equation. We won't be able to use the solution outside of this range. (I.e., \ we'll have to extend this range if we get an \"outside of range\" error \ later.)\ \>", "Text"], Cell[BoxData[ \(tmin = 0; \ tmax = 1000;\)], "Input", CellLabel->"In[14]:="], Cell["\<\ Numerically solve the differential equaiton using NDSolve, \ specifying the initial conditions. Setting MaxSteps to a large number is \ needed if tmax is large.\ \>", "Text"], Cell[BoxData[ \(\(solution\ = \ NDSolve[{diffeq, \[Theta][0] \[Equal] \[Theta]0, \ \(\[Theta]'\)[ 0] \[Equal] \[Theta]dot0}, \[Theta], {t, tmin, tmax}, MaxSteps \[Rule] 20000];\)\)], "Input", CellLabel->"In[15]:="], Cell["\<\ NDSolve returns an \"interpolating function\", which can be \ evaluated later at any time t in tmin < t < tmax.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Plot the Time Dependence and Phase Space", "Section"], Cell["\<\ We can just use \"Plot\" with Evaluate and the \"interpolating \ function\" defined by \"solution\".\ \>", "Text"], Cell[BoxData[ \(Plot[Evaluate[\[Theta][t] /. solution], {t, 0, 100}]\)], "Input", CellLabel->"In[16]:="], Cell["\<\ Or we can do a parametric plot (\"ParametricPlot\") with the same \ solution. We've added various options here to (try to) make a nicer \ plot.\ \>", "Text"], Cell[BoxData[ \(ParametricPlot[ Evaluate[{t, \[Theta][t]} /. solution], {t, 0, 100}, \[IndentingNewLine]PlotStyle \[Rule] Hue[ .6], \[IndentingNewLine]TextStyle \[Rule] {FontFamily -> \ "\", FontSize \[Rule] 14}, ImageSize \[Rule] {350, 200}, PlotLabel \[Rule] StyleForm["\