(*^
::[ 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, 14, "Times";
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 08
Series, Limits, Numerical Determination of Roots of Equations, and Numerical Integration
:[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. Finding limits using Limit[].
2. Determining Taylor Series expansions with Series[] and Normal[].
3. Using FindRoot[] to determine the roots of an equation numerically.
4. Other MMA "root" commands.
5. Numerical integration with NIntegrate[].
;[s]
11:0,0;26,1;33,0;82,1;90,0;97,1;105,0;118,1;128,0;244,1;256,0;258,-1;
2:6,16,12,Times,0,14,0,0,0;5,15,11,Courier,0,14,0,0,0;
:[font = section; inactive; preserveAspect; startGroup]
Problem
:[font = special1; inactive; preserveAspect]
Sarah, the rocketeer, is in free fall but is controlling her downward acceleration so that a[t] = - g e-ct , where c is a positive constant. Assume that Sarah starts at a height x[0] above the ground with zero initial velocity.
;[s]
3:0,0;105,1;108,0;235,-1;
2:2,16,12,Times,0,14,0,0,0;1,24,16,Times,32,14,0,0,0;
:[font = special1; inactive; preserveAspect]
a. Set up equations for v[t] and x[t] as functions of c and t using MMA's Integrate[] function.
;[s]
3:0,0;84,1;95,0;107,-1;
2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0;
:[font = special1; inactive; preserveAspect]
b. Show that these equations reduce to the appropriate free fall results when c is zero.
:[font = special1; inactive; preserveAspect]
c. Find the value of the time to at which Sarah strikes the ground.
:[font = special1; inactive; preserveAspect; endGroup]
d. Now suppose a[t] = -g cos[sin[ct]]. Set up equations for v[t] and x[t] as functions of c and t using MMA's NIntegrate[] function. Then plot v[t] and x[t] from t = 0.0 to t = 8.0 using x[0] = 100, g = 9.8, and c = 0.5.
;[s]
3:0,0;125,1;137,0;249,-1;
2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0;
:[font = section; inactive; preserveAspect; startGroup]
Solution - Part a
:[font = subsection; inactive; preserveAspect; startGroup]
Step 1 - Using Integrate[], complete the following code that defines a, v, and x as functions of c and t.
;[s]
3:0,0;16,1;27,0;115,-1;
2:2,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0;
:[font = input; preserveAspect; endGroup]
Clear[c, g, xo, a, v, x, t, s]
a[c_, t_] = -g Exp[-c t]
v[c_, t_] =
x[c_, t_] = xo +
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 1
:[font = special1; inactive; preserveAspect; endGroup; endGroup]
1. Do your results look reasonable?
:[font = section; inactive; preserveAspect; startGroup]
Solution - Part b
:[font = subsection; inactive; preserveAspect]
Step 1 - Try to evaluate your functions at c = 0. Describe what happens.
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 1
:[font = special1; inactive; preserveAspect; endGroup]
1. Infinities and indeterminate results occur for v and x.
a. Infinity is a positive real infinite quantity.
b. -Infinity is a negative real infinite quantity.
c. ComplexInfinity is a quantity with infinite magnitude, but
undetermined complex phase.
d. Indeterminate is a numerical quantity whose magnitude can't be
determined.
;[s]
9:0,0;72,1;80,0;129,1;138,0;187,1;202,0;294,1;307,0;380,-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 2 - You can find the limiting results using a MMA function. Any guess what it's called? Use Appendix 8 in Wolfram to find out about this command and then apply the command to determine the three desired limits.
:[font = subsection; inactive; preserveAspect]
Step 3 - Some physicists would find these limits by doing Taylor Series expansions on the functions about c = 0. Find out information about the MMA command Series[] and apply it to determine the Taylor Series expansion of x[c, t] to third order. Name the latter expression xSeries so you can refer to it later.
;[s]
7:0,0;160,1;168,0;228,1;236,0;281,1;288,0;320,-1;
2:4,16,12,Times,1,14,0,0,0;3,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 3
:[font = special1; inactive; preserveAspect; endGroup]
1. What's the error message telling you?
2. What's the meaning of the term O[c]4?
;[s]
4:0,0;79,1;83,2;84,0;87,-1;
3:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0;1,23,15,Courier,32,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 4 - For c = 0.5, xo = 100, and g = 9.8, plot the third order approximation to x[c, t] and the corresponding exact result on the same graph. To convert xSeries into a function, you must first remove the order term. To do so, use the MMA command Normal[]. Find out about this command and use it to produce a function xApprox[c, t] which gives the desired third order approximation. Then create the plot over the time interval between t = 0.0 and t = 8.0.
;[s]
9:0,0;90,1;97,0;166,1;173,0;262,1;270,0;335,1;349,0;477,-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; endGroup]
1. What Plot[] options did you used?
2. How might you effectively use color in your plot?
;[s]
3:0,0;10,1;16,0;96,-1;
2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0;
:[font = section; inactive; preserveAspect; startGroup]
Solution - Part c
:[font = subsection; inactive; preserveAspect]
Step 1 - Try to use Solve[] to find the time to at which Sarah strikes the ground. Be sure to use Clear[g, xo, c, to] before you invoke Solve[]. Why? What do you find?
;[s]
7:0,0;21,1;28,0;104,1;124,0;144,1;151,0;180,-1;
2:4,16,12,Times,1,14,0,0,0;3,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 1
:[font = special1; inactive; preserveAspect; endGroup]
1. Did you use double equal signs for the equation?
2. Remember, if MMA can't valuate something, it will echo what you typed back to the screen.
3. Why can't this equation to solved symbolically.
4. What are two possible ways you might solve it?
:[font = subsection; inactive; preserveAspect]
Step 2 - Assume c = 0.5, xo = 100, and g = 9.8. First make a plot of x[c, t] to estimate the time to where x[to] is zero. What do you find?
;[s]
3:0,0;74,1;81,0;151,-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 2
:[font = special1; inactive; preserveAspect; endGroup]
1. You should find that to is about 7.1. Remember, you can press the key and move the mouse to read off coordinates from a graph.
;[s]
3:0,0;75,1;84,0;147,-1;
2:2,16,12,Times,0,14,0,0,0;1,15,11,Helvetica,0,14,0,0,0;
:[font = subsection; inactive; preserveAspect]
Step 3 - You can improve your estimation by numerically determining the root of the equation x[0.5, t] == 0. The MMA command to do this numerical calculation is FindRoot[]. Find out information about this command and use it to determine to. Call the result myRoot. Then find the values for x[to] and v[to] using replacement rules.
;[s]
7:0,0;95,1;109,0;165,1;175,0;265,1;271,0;344,-1;
2:4,16,12,Times,1,14,0,0,0;3,15,11,Courier,1,14,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 3
:[font = special1; inactive; preserveAspect; endGroup; endGroup]
1. The FindRoot[] algorithm uses Newton's method, so the derivatives can't be too small. If there are multiple zeros, you may not get the root you want -- that's why a graph is very helpful.
2. There are other MMA functions that find roots of equations: Roots[], NRoot[], and NSolve[]. You may want to explore these commands later.
;[s]
9:0,0;9,1;19,0;260,1;267,0;270,1;277,0;285,1;293,0;342,-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]
Solution - Part d
:[font = subsection; inactive; preserveAspect]
Step 1 - Suppose Sarah's acceleration is given by -g cos[sin[c t]] with c = 0.5, xo = 100, and g = 9.8. Cut and paste the equations from Step 1 of Part a. Change the expression for the acceleration to the desired form and activate the cell. What the output implying?
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 1
:[font = special1; inactive; preserveAspect; endGroup]
1. If you can't integrate something symbolically, what might you try?
:[font = subsection; inactive; preserveAspect; startGroup]
Step 2 - Get information of the MMA command NIntegrate[]. What do you find? Apply this function to determine the following integrals
;[s]
3:0,0;45,1;57,0;136,-1;
2:2,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0;
:[font = input; preserveAspect; endGroup]
1/(1 + Exp[x]) from 0 to Infinite
Exp[Cos[x]] from 0 to 2 Pi
Sin[x] BesselJ[0, x] from 0 to 1
;[s]
13:0,0;23,1;27,0;32,1;34,0;68,1;72,0;77,1;79,0;109,1;113,0;118,1;120,0;124,-1;
2:7,13,10,Courier,1,12,0,0,0;6,13,9,Times,1,12,0,0,0;
:[font = subsection; inactive; preserveAspect; startGroup]
Step 3 - The following code defines v and x in terms of NIntegrate[]. Look over the code and then activate the cell.
;[s]
3:0,0;63,1;75,0;126,-1;
2:2,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0;
:[font = input; preserveAspect; endGroup]
Clear[c, g, xo, a, v, x, t, s]
a[c_, t_] = -g Cos[Sin[c t]];
v[c_, t_] := NIntegrate[a[c, s], {s, 0, t}]
x[c_, t_] := xo + NIntegrate[v[c, s], {s, 0, t}]
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 3
:[font = special1; inactive; preserveAspect; endGroup]
1. Why is SetDelayed[] used to define v[] and x[]?
1. Note that SetDelayed[] does not echo its results to the screen.
;[s]
9:0,0;12,1;24,0;42,1;46,0;52,1;55,0;72,1;84,0;127,-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 4 - Use these function to plot Sarah's velocity and position from t = 0.0 and t = 8.0 for the parameters g = 9.8, xo = 100, and c = 0.5. Be sure to label the axes on your plot.
:[font = subsection; inactive; preserveAspect; startGroup]
Comment 4
:[font = special1; inactive; preserveAspect; endGroup; endGroup]
1. Why did it take so long to do the plots?
:[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 myEx08.
;[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;
^*)