(************** 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[ 12427, 420]*) (*NotebookOutlinePosition[ 13287, 451]*) (* CellTagsIndexPosition[ 13243, 447]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{Cell["\<\ Example 10 Symbolic and Numerical Solutions to Differential Equations I\ \>", "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. ", StyleBox["DSolve[]", FontFamily->"Courier"], ".\n2. Brief mention of anonymous functions.\n3. ", StyleBox["NDSolve[]", FontFamily->"Courier"], ".\n4. ", StyleBox["InterpolatingFunction[]", FontFamily->"Courier"], ". \n5. ", StyleBox["Short[]", FontFamily->"Courier"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Problem", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ A particle of mass m in one dimensional free fall motion experiences a \ retarding force due to air that's proportional to the particle's velocity, \ i.e, Ff = -cv, where c is a positive constant. If the coordinate system points \ vertically downward and the particle starts out with the initial velocity \ v[0] at position x[0], what's the expression for its velocity as a \ function of time. \ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ The relevant equations: dv/dt = g - bv and b = c/m .\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 1 - The MMA command that symbolically solve differential equations \ (DEQ) is ", StyleBox["DSolve[]", FontFamily->"Courier"], ". What can you find out about this command?" }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 1", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Make sure you look at the options for ", StyleBox["DSolve[]", FontFamily->"Courier"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell[TextData[{ "Step 2 - Activate the code below which solves the DEQ for ", StyleBox["v[t]", FontFamily->"Courier"], ", but without specifing any initial conditions. Note that the derivative \ of ", StyleBox["v[t]", FontFamily->"Courier"], " is denoted by ", StyleBox["v'[t]", FontFamily->"Courier"], " and that the output is called ", StyleBox["soln1", FontFamily->"Courier"], ". " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Clear[v, b, g, soln1] soln1 = DSolve[v'[t] + b v[t] - g == 0, v[t], t]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Comment 2", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Remember to always use double equal signs for equations.\n2. What's \ the form of the output for ", StyleBox["soln1", FontFamily->"Courier"], "?\n3. What's ", StyleBox["C[1]", FontFamily->"Courier"], "? What do you think the one option for ", StyleBox["DSolve[]", FontFamily->"Courier"], " does? Try it out.\n4. What's the derivative symbol ", StyleBox["'", FontFamily->"Courier"], " about? Hint: look at the MMA command ", StyleBox["Derivative[]", FontFamily->"Courier"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 3 - Repeat Step 2 but add the initial condition ", StyleBox["v[0] == vo", FontFamily->"Courier"], " to the equation list. Name the output ", StyleBox["soln2", FontFamily->"Courier"], ". Remember that there are now two equations and they should appear in a \ list." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 3", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. You might want to line up the equations to make the code easier to \ read.\n2. It's important to have ", StyleBox["v[t] ", FontFamily->"Courier"], " (but not ", StyleBox["v", FontFamily->"Courier"], ") in the second to last slot in the argument of ", StyleBox["DSolve[]", FontFamily->"Courier"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 4 - See what happens if you replace ", StyleBox["v[t]", FontFamily->"Courier"], " by ", StyleBox["v", FontFamily->"Courier"], " in the second to last slot in the argument of ", StyleBox["DSolve[]", FontFamily->"Courier"], ". Name this output ", StyleBox["soln3", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 4", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. You should either see the word ", StyleBox["Function", FontFamily->"Courier"], " or a bunch of ", StyleBox["#", FontFamily->"Courier"], " and ", StyleBox["&", FontFamily->"Courier"], " symbols. These quantities are used to define what MMA calls anonymous \ or pure functions, i.e., functions with no names (see Wolfram, Sec. 2.2.5, \ or Blachman, Chapter 12 for more details). For now, make sure to use ", StyleBox["v[t] ", FontFamily->"Courier"], "in this slot." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 5 - Create a function ", StyleBox["vel1[t, vo, b, g]", FontFamily->"Courier"], " that corresponds to the velocity expression found in ", StyleBox["soln2", FontFamily->"Courier"], ". Show in two ways that the results agree with what you expect to happen \ as b goes to zero. (Hint: what's ", StyleBox["soln2[[1,1,2]]", FontFamily->"Courier"], " ?)" }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 6 - Create a plot, called ", StyleBox["plot1", FontFamily->"Courier"], ", of ", StyleBox["vel1[t, vo, b, g]", FontFamily->"Courier"], " for 0.0 < t < 30.0 when b = 0.1, g = 9.8, and vo = 0.0. Be sure \ to label your axes." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 7 - Suppose the particle experiences a force due to air that's \ proportional to the cube of the particle's speed, i.e., Ff = -bv", StyleBox["3", FontVariations->{"CompatibilityType"->"Superscript"}], ". Assuming v[0] is vo, what's v[t]? Call the output to ", StyleBox["DSolve[],", FontFamily->"Courier"], " in this case, ", StyleBox["soln4", FontFamily->"Courier"], ". " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 7", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1. MMA didn't solve this problem symbolically, eventhough you can. But \ there's probably a way for MMA to do it. 2. However, if you can't solve something symbolically, how else could it be \ done?\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell["\<\ Step 8 - What do you think is the MMA command for numerically solving DEQs? \ Find out.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 8", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. How do the arguments of ", StyleBox["NDSolve[]", FontFamily->"Courier"], " and ", StyleBox["DSolve[] ", FontFamily->"Courier"], " differ?\n2. As with ", StyleBox["DSolve[]", FontFamily->"Courier"], ", you can call the dependent variable either y or y[x]; if you don't \ want anonymous functions, use y[x]." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 9 - Numerically solve the DEQ for the cubic air resistance, assuming \ b = 0.1, g = 9.8, and vo = 0.0. Consider the time interval from t = 0.0 \ to 30.0. Call the output ", StyleBox["soln5", FontFamily->"Courier"], "." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 9", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Get help on ", StyleBox["InterpolatingFunction[]", FontFamily->"Courier"], ".\n2. So ", StyleBox["InterpolatingFunction[]", FontFamily->"Courier"], " is a function which, when applied to t, gives an approximate value for \ v[t]. \n3. Specific values are stored in a table and an interpolating \ algorithm is then used to find the desired value.\n4. Why does having an \ interpolating function make sense for a numerical solution to a DEQ?\n5. To \ see what's hidden behind ", StyleBox["InterpolationFunction[]", FontFamily->"Courier"], ", type ", StyleBox["FullForm[soln5]]", FontFamily->"Courier"], ". What's this ", StyleBox["List", FontFamily->"Courier"], " stuff about?\n6. So what do you think ", StyleBox["<>", FontFamily->"Courier"], " means in the output for ", StyleBox["soln5", FontFamily->"Courier"], "? Look up the MMA command ", StyleBox["Short[]", FontFamily->"Courier"], " and apply it to ", StyleBox["Table[x^2, {x, 100}] ", FontFamily->"Courier"], " using postfix notation." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 10 - Create the function ", StyleBox["vel2[t]", FontFamily->"Courier"], " that corresponds to the interpolating function in Step 9. Then produce \ a plot, named ", StyleBox["plot2", FontFamily->"Courier"], ", of the velocity for t = 0.0 to t = 30.0." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 11 - Display both the linear and cubic results for the velocity of \ the particle on a single plot using ", StyleBox["Show[]", FontFamily->"Courier"], ". Include the option\n\n ", StyleBox["PlotRange -> All", FontFamily->"Courier"], " " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 11", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. What happens if you didn't set ", StyleBox[" PlotRange", FontFamily->"Courier"], " to ", StyleBox["All", FontFamily->"Courier"], "? Try it." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]]}, 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["myEx10", 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, 113}, {Automatic, 0}}, 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, 129, 4, 70, "Title"], Cell[1859, 58, 265, 7, 70, "Subsubtitle"], Cell[CellGroupData[{ Cell[2147, 67, 69, 1, 70, "Section"], Cell[2219, 70, 383, 15, 70, "Special1"] }, Open ]], Cell[CellGroupData[{ Cell[2634, 87, 59, 1, 70, "Section"], Cell[2696, 90, 466, 9, 70, "Special1"], Cell[3165, 101, 129, 3, 70, "Special1"], Cell[3297, 106, 256, 7, 70, "Subsection"], Cell[CellGroupData[{ Cell[3576, 115, 64, 1, 70, "Subsection"], Cell[3643, 118, 170, 6, 70, "Special1"] }, Open ]], Cell[CellGroupData[{ Cell[3845, 126, 476, 16, 70, "Subsection"], Cell[4324, 144, 128, 4, 70, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[4484, 150, 64, 1, 70, "Subsection"], Cell[4551, 153, 602, 19, 70, "Special1"] }, Open ]], Cell[5165, 174, 360, 10, 70, "Subsection"], Cell[CellGroupData[{ Cell[5548, 186, 64, 1, 70, "Subsection"], Cell[5615, 189, 400, 13, 70, "Special1"] }, Open ]], Cell[6027, 204, 404, 15, 70, "Subsection"], Cell[CellGroupData[{ Cell[6454, 221, 64, 1, 70, "Subsection"], Cell[6521, 224, 577, 17, 70, "Special1"] }, Open ]], Cell[7110, 243, 454, 13, 70, "Subsection"], Cell[7567, 258, 325, 10, 70, "Subsection"], Cell[7895, 270, 479, 13, 70, "Subsection"], Cell[CellGroupData[{ Cell[8397, 285, 64, 1, 70, "Subsection"], Cell[8464, 288, 262, 6, 70, "Special1"] }, Open ]], Cell[8738, 296, 151, 4, 70, "Subsection"], Cell[CellGroupData[{ Cell[8912, 302, 64, 1, 70, "Subsection"], Cell[8979, 305, 411, 13, 70, "Special1"] }, Open ]], Cell[9402, 320, 312, 8, 70, "Subsection"], Cell[CellGroupData[{ Cell[9737, 330, 64, 1, 70, "Subsection"], Cell[9804, 333, 1160, 34, 70, "Special1"] }, Open ]], Cell[10976, 369, 351, 10, 70, "Subsection"], Cell[11330, 381, 357, 10, 70, "Subsection"], Cell[CellGroupData[{ Cell[11710, 393, 65, 1, 70, "Subsection"], Cell[11778, 396, 231, 9, 70, "Special1"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[12050, 407, 70, 1, 70, "Section"], Cell[12123, 410, 283, 9, 70, "Special1"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)