(************** 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[ 15092, 483]*) (*NotebookOutlinePosition[ 15952, 514]*) (* CellTagsIndexPosition[ 15908, 510]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{Cell["\<\ Example 11 Symbolic and Numerical Solutions to Differential Equations II\ \>", "Title", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Copyright ", StyleBox["\[Copyright]", FontSlant->"Plain"], " 1993 by Bill Titus, Carleton College, \nDepartment of Physics and \ Astronomy, Northfield, MN 55057-4025\nSeptember 6, 1993" }], "Subsubtitle", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Topics and Skills", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Packages: general information and loading packages with ", StyleBox["Needs[]", FontFamily->"Courier"], ".\n2. Manipulating complex exponentials: ", StyleBox["ComplexToTrig[]", FontFamily->"Courier"], " in the package ", StyleBox["\"Algebra`Trigonometry`\"", FontFamily->"Courier"], ".\n3. ", StyleBox["ParametricPlot3D[]", FontFamily->"Courier"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Problem", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ a. Find the symbolic solution to the DEQ for the simple harmonic oscillator \ (SHO) with angular frequency w. In particular, solve the equation first as \ a second order DEQ, and then as a set to two, coupled first order DEQs. \ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ b. Find the solution to the simple harmonic oscillator when there's an \ additional damping term present that's proportional to the oscillator's \ velocity.\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Solution - Part a", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 1 - Find the symbolic solution to the DEQ of the SHO without \ specifying any initial conditions. Call your result ", StyleBox["soln1", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 1", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1. Note that the solution is given in terms of complex exponentials. Why?\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 2 - Repeat Step 1, but now specify the initial conditions\n", StyleBox["x[0] == xo", FontFamily->"Courier"], " and ", StyleBox["x'[0] == vo", FontFamily->"Courier"], " by placing these equations in ", StyleBox["DSolve[]", FontFamily->"Courier"], "'s equation list along with the DEQ. Call the result ", StyleBox["soln2", FontFamily->"Courier"], ". " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 2", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. The results are still in terms of complex exponentials.\n2. Did you \ line up your equations to make them easier to read?\n3. It would be nice to \ convert the complex exponentials to trigonometric functions. You can do that \ with the command ", StyleBox["ComplexToTrig[]", FontFamily->"Courier"], ". However, this function is not yet loaded.\n4. There are a large number \ of functions written in MMA's own programming language which extends MMA's \ default library of functions. These functions are in packages, where each \ package is associated with a file having a ", StyleBox[".m", FontFamily->"Courier"], " extension. \n5. There is a list of packages in Appendix D of Blachman \ and more detailed information in the MMA Technical Report, ", StyleBox["Guide to Standard Mathematica Packages", FontSlant->"Italic"], ". \n6. You access these additional functions by first loading specific \ packages with the MMA function ", StyleBox["Needs[]", FontFamily->"Courier"], ", the argument of which is the \"context\" for the package. For the \ function ", StyleBox["ComplexToTrig[]", FontFamily->"Courier"], ", the context is ", StyleBox["\"Algebra`Trigonometry`\"", FontFamily->"Courier"], ". You may want to think of the context as a directory containing the \ various packages." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 3 - Load the package ", StyleBox["\"Algebra`Trigonometry`\"", FontFamily->"Courier"], " by placing this context as the argument in ", StyleBox["Needs[]", FontFamily->"Courier"], ". You'll need to include the double quotes in the argument. Then find \ out what you can about the function ", StyleBox["ComplexToTrig[]", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 3", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. What problems might have occurred if you had defined your own function \ ", StyleBox["ComplexToTrig[]", FontFamily->"Courier"], " before loading the one from the package ", StyleBox["\"Algebra`Trigonometry`\"", FontFamily->"Courier"], "?\n2. How could you avoid this problem? Hint: remember ", StyleBox["Remove[]", FontFamily->"Courier"], "?" }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 4 - Find out what other functions exist in the package you just \ loaded by typing in ", StyleBox["?Algebra`Trigonometry`*", FontFamily->"Courier"], " ." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 4", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["1. Does the notation for the above help command make sense?", \ "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 5 - Apply ", StyleBox["ComplexToTrig[]", FontFamily->"Courier"], " to both ", StyleBox["soln1", FontFamily->"Courier"], " and ", StyleBox["soln2", FontFamily->"Courier"], ", and then apply ", StyleBox["Simplify[]", FontFamily->"Courier"], " to your results to make them look nicer, using postfix notation. Call \ your new results ", StyleBox["soln3", FontFamily->"Courier"], " and ", StyleBox["soln4", FontFamily->"Courier"], ", respectively. " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 6 - Now solve the SHO as a coupled set of first order DEQ\n\n \ ", StyleBox["dv[t]/dt == -w^2 x[t]\n dx[t]/dt == v[t] \n", FontFamily->"Courier"], "\nsubject to the initial conditions ", StyleBox["x[0] == xo", FontFamily->"Courier"], " and ", StyleBox["v[0] == vo", FontFamily->"Courier"], ". Call the result ", StyleBox["soln5", FontFamily->"Courier"], ". Then convert your solutions to trig functions, simplify the expressions \ as much as possible, and call the final result ", StyleBox["soln6", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 6", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. ", StyleBox["DSolve[] ", FontFamily->"Courier"], "doesn't seen to work with coupled differential equations other than first \ order." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ StyleBox["Step 7 - Using the appropriate parts of ", FontWeight->"Bold"], StyleBox["soln6", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[" (like, for example, ", FontWeight->"Bold"], StyleBox["soln6[[1,1,2]]", FontFamily->"Courier", FontWeight->"Bold"], StyleBox["), create position and velocity functions that depend on t, w, \ xo, and vo. Then use ", FontWeight->"Bold"], StyleBox["Plot[]", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[" to display x[t] and v[t] as functions of time. Finally, use \ ", FontWeight->"Bold"], StyleBox["ParametricPlot[]", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[" to draw a phase plot, i.e, a plot of x[t] versus v[t]. \ For plotting purposes, assume that w = 1.0, xo = 1.0, vo = 0.0, and \ 0.0 < t < 10.0.", FontWeight->"Bold"] }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}, FontWeight->"Plain"], Cell[CellGroupData[{Cell["Comment 7", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. If your phase plot doesn't look like a circle, make it so by setting \ the option ", StyleBox["AspectRatio", FontFamily->"Courier"], " to ", StyleBox["1", FontFamily->"Courier"], " or ", StyleBox["Automatic", FontFamily->"Courier"], ". What do you think is the difference between these two options?" }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell["\<\ Step 8 - Create an extended phase space plot by including a third axis that \ corresponds to time. What command do you think would plot this type of three \ dimensional, parametric curve? Find the command and create the plot. \ However, to begin with, don't use any plot options.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 8", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. You may need to resize the plot to make it look nicer. Do so by \ disabling the setting ", StyleBox["Graph \\ Preserve aspect ratio", FontFamily->"Helvetica"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 9 - Look at the options for ", StyleBox["ParametricPlot3D[]", FontFamily->"Courier"], ". Find the one that will allow you to look at the plot from different \ view points." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 9", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Many of the options should look familiar. Where have you seen them \ before?\n2. Not surprisingly, ", StyleBox["ViewPoint", FontFamily->"Courier"], " is the option that affects the view from which the plot is observed." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 10 - Find out about ", StyleBox["ViewPoint", FontFamily->"Courier"], " and use it to look at your plot from different angles. Also, label your \ axes using an appropriate plot option." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 11", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. The ", StyleBox["ViewPoint", FontFamily->"Courier"], " coordinates are relative to the center of the box, and are scaled so \ that the longest side of the box corresponds to one unit.\n2. MMA can \ determine viewpoints automatically for you through its 3D ViewPoint Selector. \ " }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 12 - Position your curor in your", StyleBox[" ParametricPlot[]", FontFamily->"Courier"], " command just before the final left bracket of the command. Then select \ the menu item ", StyleBox["Action \\ PrepareInput \\ 3D ViewPoint Selector", FontFamily->"Helvetica"], " and rotate the 3D box until you get a view of the plot that appeals to \ you. Press ", StyleBox["Insert", FontFamily->"Helvetica"], " or ", StyleBox["Paste", FontFamily->"Helvetica"], " and the corresponding ", StyleBox["ViewPoint", FontFamily->"Helvetica"], " option will be inserted into your ", StyleBox["ParametricPlot[]", FontFamily->"Courier"], " command. Finally ", StyleBox["", FontFamily->"Helvetica"], " your results." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Solution - Part b", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 1 - Solve the damped SHO for the position and velocity as functions \ of time for initial conditions x[0] = xo and v[0] = vo. Do this by \ solving a set of two, first order coupled DEQ. Call your result ", StyleBox["soln7", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 1", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Why are the solutions so ugly? \n2. Can you simplify the solutions? \ Would you want to?\n3. For simplification techniques, see Abell and \ Braselton, ", StyleBox["Mathematica by Example", FontSlant->"Italic"], ", pp. 429 - 434." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 2 - Solve the DSHO numerically using ", StyleBox["NDSolve[]", FontFamily->"Courier"], ". Assume that xo = 1.0, vo = 0.0, w = 1.0, b = 0.3, and 0.0 < t < \ 20.0. Call your result ", StyleBox["soln8", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Step 3 - Create velocity and position functions and use them to produce the \ same type of two dimensional plots as you did for the SHO. \ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Save Your Notebook", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Remove any output cells from this notebook and then use ", StyleBox["Save As", FontFamily->"Helvetica"], " to store your notebook under the name ", StyleBox["myEx11", FontFamily->"Helvetica"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]]}, Open]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowToolbars->{}, CellGrouping->Manual, WindowSize->{499, 599}, WindowMargins->{{Automatic, 76}, {23, Automatic}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False} ] (******************************************************************* 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[CellGroupData[{ Cell[1727, 52, 131, 5, 70, "Title"], Cell[1861, 59, 265, 7, 70, "Subsubtitle"], Cell[CellGroupData[{ Cell[2149, 68, 69, 1, 70, "Section"], Cell[2221, 71, 461, 15, 70, "Special1"] }, Open ]], Cell[CellGroupData[{ Cell[2714, 88, 59, 1, 70, "Section"], Cell[2776, 91, 293, 5, 70, "Special1"], Cell[3072, 98, 218, 5, 70, "Special1"] }, Open ]], Cell[CellGroupData[{ Cell[3322, 105, 69, 1, 70, "Section"], Cell[3394, 108, 248, 7, 70, "Subsection"], Cell[CellGroupData[{ Cell[3665, 117, 64, 1, 70, "Subsection"], Cell[3732, 120, 136, 3, 70, "Special1"] }, Open ]], Cell[3880, 125, 462, 15, 70, "Subsection"], Cell[CellGroupData[{ Cell[4365, 142, 64, 1, 70, "Subsection"], Cell[4432, 145, 1418, 31, 70, "Special1"] }, Open ]], Cell[5862, 178, 451, 13, 70, "Subsection"], Cell[CellGroupData[{ Cell[6336, 193, 64, 1, 70, "Subsection"], Cell[6403, 196, 443, 13, 70, "Special1"] }, Open ]], Cell[6858, 211, 237, 7, 70, "Subsection"], Cell[CellGroupData[{ Cell[7118, 220, 64, 1, 70, "Subsection"], Cell[7185, 223, 115, 2, 70, "Special1"] }, Open ]], Cell[7312, 227, 580, 22, 70, "Subsection"], Cell[7895, 251, 657, 20, 70, "Subsection"], Cell[CellGroupData[{ Cell[8575, 273, 64, 1, 70, "Subsection"], Cell[8642, 276, 213, 7, 70, "Special1"] }, Open ]], Cell[8867, 285, 980, 29, 70, "Subsection"], Cell[CellGroupData[{ Cell[9870, 316, 64, 1, 70, "Subsection"], Cell[9937, 319, 401, 13, 70, "Special1"] }, Open ]], Cell[10350, 334, 345, 6, 70, "Subsection"], Cell[CellGroupData[{ Cell[10718, 342, 64, 1, 70, "Subsection"], Cell[10785, 345, 245, 7, 70, "Special1"] }, Open ]], Cell[11042, 354, 257, 7, 70, "Subsection"], Cell[CellGroupData[{ Cell[11322, 363, 64, 1, 70, "Subsection"], Cell[11389, 366, 302, 7, 70, "Special1"] }, Open ]], Cell[11703, 375, 270, 7, 70, "Subsection"], Cell[CellGroupData[{ Cell[11996, 384, 65, 1, 70, "Subsection"], Cell[12064, 387, 362, 9, 70, "Special1"] }, Open ]], Cell[12438, 398, 855, 26, 70, "Subsection"] }, Open ]], Cell[CellGroupData[{ Cell[13325, 426, 69, 1, 70, "Section"], Cell[13397, 429, 340, 8, 70, "Subsection"], Cell[CellGroupData[{ Cell[13760, 439, 64, 1, 70, "Subsection"], Cell[13827, 442, 313, 8, 70, "Special1"] }, Open ]], Cell[14152, 452, 328, 10, 70, "Subsection"], Cell[14483, 464, 200, 4, 70, "Subsection"] }, Open ]], Cell[CellGroupData[{ Cell[14715, 470, 70, 1, 70, "Section"], Cell[14788, 473, 283, 9, 70, "Special1"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)