(*^
::[ Information =
"This is a Mathematica Notebook file. It contains ASCII text, and can be
transferred by email, ftp, or other text-file transfer utility. It should
be read or edited using a copy of Mathematica or MathReader. If you
received this as email, use your mail application or copy/paste to save
everything from the line containing (*^ down to the line containing ^*)
into a plain text file. On some systems you may have to give the file a
name ending with ".ma" to allow Mathematica to recognize it as a Notebook.
The line below identifies what version of Mathematica created this file,
but it can be opened using any other version as well.";
FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2";
MacintoshStandardFontEncoding;
fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times";
fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times";
fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times";
fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times";
fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times";
fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times";
fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = input, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, 12, "Courier";
fontset = output, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-4, 12, "Courier";
fontset = message, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, 12, "Courier";
fontset = print, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, 12, "Courier";
fontset = info, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, 12, "Courier";
fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier";
fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Times";
fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
fontset = leftheader, inactive, L2, 12, "Times";
fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, 12, "";
fontset = leftfooter, inactive, L2, 12, "Times";
fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Courier";
fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 14, "Times";
fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "";
paletteColors = 128; automaticGrouping; currentKernel;
]
:[font = title; inactive; preserveAspect; startGroup]
Example 10
Symbolic and Numerical Solutions to Differential Equations I
:[font = subsubtitle; inactive; preserveAspect]
Copyright ã 1993 by Bill Titus, Carleton College,
Department of Physics and Astronomy, Northfield, MN 55057-4025
September 6, 1993
;[s]
3:0,0;10,1;11,0;133,-1;
2:2,16,12,Times,2,14,0,0,0;1,16,12,Symbol,0,14,0,0,0;
:[font = section; inactive; preserveAspect; startGroup]
Topics and Skills
:[font = special1; inactive; preserveAspect; endGroup]
1. DSolve[].
2. Brief mention of anonymous functions.
3. NDSolve[].
4. InterpolatingFunction[].
5. Short[].
;[s]
9:0,0;4,1;12,0;60,1;69,0;75,1;98,0;106,1;113,0;115,-1;
2:5,16,12,Times,0,14,0,0,0;4,15,11,Courier,0,14,0,0,0;
:[font = section; inactive; preserveAspect; startGroup]
Problem
:[font = special1; inactive; preserveAspect]
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.
:[font = special1; inactive; preserveAspect]
The relevant equations: dv/dt = g - bv and b = c/m .
:[font = subsection; inactive; preserveAspect]
Step 1 - The MMA command that symbolically solve differential equations (DEQ) is DSolve[]. What can you find out about this command?
;[s]
3:0,0;82,1;90,0;135,-1;
2:2,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 1
:[font = special1; inactive; preserveAspect; endGroup]
1. Make sure you look at the options for DSolve[].
;[s]
3:0,0;43,1;51,0;53,-1;
2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Step 2 - Activate the code below which solves the DEQ for v[t], but without specifing any initial conditions. Note that the derivative of v[t] is denoted by v'[t] and that the output is called soln1.
;[s]
9:0,0;59,1;63,0;141,1;145,0;162,1;167,0;199,1;204,0;208,-1;
2:5,16,12,Times,1,14,0,0,0;4,15,11,Courier,1,14,0,0,0;
:[font = input; preserveAspect; endGroup]
Clear[v, b, g, soln1]
soln1 = DSolve[v'[t] + b v[t] - g == 0, v[t], t]
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 2
:[font = special1; inactive; preserveAspect; endGroup]
1. Remember to always use double equal signs for equations.
2. What's the form of the output for soln1?
3. What's C[1]? What do you think the one option for DSolve[] does? Try it out.
4. What's the derivative symbol ' about? Hint: look at the MMA command Derivative[].
;[s]
11:0,0;100,1;105,0;119,1;123,0;164,1;172,0;227,1;228,0;270,1;282,0;284,-1;
2:6,16,12,Times,0,14,0,0,0;5,15,11,Courier,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 3 - Repeat Step 2 but add the initial condition v[0] == vo to the equation list. Name the output soln2. Remember that there are now two equations and they should appear in a list.
;[s]
5:0,0;54,1;64,0;106,1;111,0;190,-1;
2:3,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 3
:[font = special1; inactive; preserveAspect; endGroup]
1. You might want to line up the equations to make the code easier to read.
2. It's important to have v[t] (but not v) in the second to last slot in the argument of DSolve[].
;[s]
7:0,0;105,1;110,0;121,1;122,0;172,1;180,0;182,-1;
2:4,16,12,Times,0,14,0,0,0;3,15,11,Courier,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 4 - See what happens if you replace v[t] by v in the second to last slot in the argument of DSolve[]. Name this output soln3.
;[s]
9:0,0;42,1;46,0;52,1;53,0;102,1;110,0;131,1;136,0;138,-1;
2:5,16,12,Times,1,14,0,0,0;4,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 4
:[font = special1; inactive; preserveAspect; endGroup]
1. You should either see the word Function or a bunch of # and & 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 v[t] in this slot.
;[s]
9:0,0;36,1;44,0;61,1;62,0;69,1;70,0;290,1;295,0;309,-1;
2:5,16,12,Times,0,14,0,0,0;4,15,11,Courier,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 5 - Create a function vel1[t, vo, b, g] that corresponds to the velocity expression found in soln2. Show in two ways that the results agree with what you expect to happen as b goes to zero. (Hint: what's soln2[[1,1,2]] ?)
;[s]
7:0,0;28,1;45,0;101,1;106,0;217,1;231,0;235,-1;
2:4,16,12,Times,1,14,0,0,0;3,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 6 - Create a plot, called plot1, of vel1[t, vo, b, g] for 0.0 < t < 30.0 when b = 0.1, g = 9.8, and vo = 0.0. Be sure to label your axes.
;[s]
5:0,0;32,1;37,0;44,1;61,0;155,-1;
2:3,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
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 = -bv3. Assuming v[0] is vo, what's v[t]? Call the output to DSolve[], in this case, soln4.
;[s]
7:0,0;133,1;134,0;196,2;205,0;221,2;226,0;229,-1;
3:4,16,12,Times,1,14,0,0,0;1,24,16,Times,33,14,0,0,0;2,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 7
:[font = special1; inactive; preserveAspect; endGroup]
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?
:[font = subsection; inactive; preserveAspect]
Step 8 - What do you think is the MMA command for numerically solving DEQs? Find out.
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 8
:[font = special1; inactive; preserveAspect; endGroup]
1. How do the arguments of NDSolve[] and DSolve[] differ?
2. As with DSolve[], you can call the dependent variable either y or y[x]; if you don't want anonymous functions, use y[x].
;[s]
7:0,0;29,1;38,0;45,1;54,0;76,1;84,0;193,-1;
2:4,16,12,Times,0,14,0,0,0;3,15,11,Courier,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
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 soln5.
;[s]
3:0,0;182,1;187,0;189,-1;
2:2,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 9
:[font = special1; inactive; preserveAspect; endGroup]
1. Get help on InterpolatingFunction[].
2. So InterpolatingFunction[] is a function which, when applied to t, gives an approximate value for v[t].
3. Specific values are stored in a table and an interpolating algorithm is then used to find the desired value.
4. Why does having an interpolating function make sense for a numerical solution to a DEQ?
5. To see what's hidden behind InterpolationFunction[], type FullForm[soln5]]. What's this List stuff about?
6. So what do you think <> means in the output for soln5? Look up the MMA command Short[] and apply it to Table[x^2, {x, 100}] using postfix notation.
;[s]
19:0,0;17,1;40,0;50,1;73,0;395,1;418,0;426,1;442,0;458,1;462,0;503,1;505,0;532,1;537,0;565,1;572,0;592,1;613,0;638,-1;
2:10,16,12,Times,0,14,0,0,0;9,15,11,Courier,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 10 - Create the function vel2[t] that corresponds to the interpolating function in Step 9. Then produce a plot, named plot2, of the velocity for t = 0.0 to t = 30.0.
;[s]
5:0,0;32,1;39,0;128,1;133,0;181,-1;
2:3,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 11 - Display both the linear and cubic results for the velocity of the particle on a single plot using Show[]. Include the option
PlotRange -> All
;[s]
5:0,0;109,1;115,0;157,1;173,0;185,-1;
2:3,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 11
:[font = special1; inactive; preserveAspect; endGroup; endGroup]
1. What happens if you didn't set PlotRange to All? Try it.
;[s]
5:0,0;35,1;45,0;51,1;54,0;65,-1;
2:3,16,12,Times,0,14,0,0,0;2,15,11,Courier,0,14,0,0,0;
:[font = section; inactive; preserveAspect; startGroup]
Save Your Notebook
:[font = special1; inactive; preserveAspect; endGroup; endGroup]
Remove any output cells from this notebook and then use Save As to store your notebook under the name myEx10.
;[s]
5:0,0;57,1;64,0;105,1;111,0;113,-1;
2:3,16,12,Times,0,14,0,0,0;2,15,11,Helvetica,0,14,0,0,0;
^*)