(*^ ::[ 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, "Courier"; 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 07 Symbolic Integration, Differentiation, and Equation Solving :[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. Integrate[]. 2. D[]. 3. Solve[]. 4. Simplify[] and related functions. 5. Postfix notation for functions. 6. Double bracket notation for parts of a list or expression. ;[s] 9:0,0;4,1;15,0;21,1;24,0;30,1;37,0;43,1;54,0;177,-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 ball is thrown vertically upward from a height x[0] above the ground with an initial velocity v[0]. Knowing that the acceleration -g is constant, find expressions for the velocity v[t] and the position x[t] by integrating the acceleration and velocity, respectively. Use definite integration so that the initial conditions are explicitly built-in. Then use your expressions to determine the time to at which the ball strikes the ground and the velocity v[to] upon impact. :[font = special1; inactive; preserveAspect] Recall that the equations for definite integration are: :[font = special1; inactive; preserveAspect] v[t] = v[0] + ò ot a[s] ds x[t] = x[0] + ò ot v[s] ds ;[s] 9:0,0;16,1;18,2;19,3;21,0;45,1;47,2;48,3;49,0;58,-1; 4:3,15,11,Courier,0,14,0,0,0;2,16,12,Symbol,0,14,0,0,0;2,23,15,Courier,64,14,0,0,0;2,23,15,Courier,32,14,0,0,0; :[font = subsection; inactive; preserveAspect] Step 1 - What do you think is the MMA command for integration? Find out. :[font = subsection; inactive; preserveAspect] Step 2 - Try out Integrate[] by integrating the following functions: 1. sin[x] as an indefinite integral 2. e-x as an indefinite integral 3. e-x as a definite integral from 0 to 1 4. e-x as a definite integral from 0 to infinity 5. sin[x] / x as a definite integral from 0 to infinity In 4 and 5, you can use the MMA constant Infinity as the upper limit. ;[s] 11:0,0;18,1;29,0;115,2;117,0;150,2;152,0;197,2;199,0;348,1;356,0;378,-1; 3:6,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0;3,24,16,Times,33,14,0,0,0; :[font = subsection; inactive; preserveAspect; startGroup] Comment 2 :[font = special1; inactive; preserveAspect; endGroup] 1. Did you get help on Infinity? If not, do so. 2. MMA doesn't include constants of integration with indefinite integrals. So, be careful. ;[s] 3:0,0;25,1;33,0;144,-1; 2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0; :[font = subsection; inactive; preserveAspect] Step 3 - Not surprisingly, MMA has a command D[] which take the derivative of a function. Find out about this command. ;[s] 3:0,0;47,1;50,0;123,-1; 2:2,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0; :[font = subsection; inactive; preserveAspect] Step 4 - Apply what you found in Step 3 to determine the derivatives of sin[x], x3, and tanh[sin[z2]]. ;[s] 5:0,0;83,1;84,0;102,1;103,0;107,-1; 2:3,16,12,Times,1,14,0,0,0;2,24,16,Times,33,14,0,0,0; :[font = subsection; inactive; preserveAspect; startGroup] Step 5 - Complete the following code which uses the definite integral form of Integrate[] to create functions for the velocity and position of the ball discussed in the original problem as functions of x[0], v[0], g, and t. ;[s] 5:0,0;52,2;60,0;79,1;90,0;231,-1; 3:3,16,12,Times,1,14,0,0,0;1,15,11,Courier,1,14,0,0,0;1,16,12,Times,3,14,0,0,0; :[font = input; preserveAspect; endGroup] Clear[g, vo, xo, a, v, x, t, s] a[t_, g_] = -g v[xo_, vo_, t_, g_] = vo + x[xo_, vo_, t_, g_] = xo + :[font = subsection; inactive; preserveAspect] Step 6 - You now want to solve the equation x[to] = 0 for the time to that the ball strikes the ground, and then use that time to find v[to]. The MMA command you want to use is, not surprisingly, Solve[]. Find out about this function. ;[s] 3:0,0;204,1;211,0;244,-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 6 :[font = special1; inactive; preserveAspect; endGroup] 1. To apply Solve[], you'll need to know that equations in MMA are indicated with a double equal sign, not a single equal sign. For example, the equation you need to solve for to is x[xo, vo, to, g] == 0. ;[s] 7:0,0;14,1;21,0;180,1;182,0;190,1;211,0;213,-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 7 - Solve your position equation for to and name the output soln. Describe the form in which soln appears. ;[s] 5:0,0;68,1;72,0;104,1;108,0;119,-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 7 :[font = special1; inactive; preserveAspect; endGroup] 1. Why are there two solutions? 2. The output is given in the form of a list of replacement rules; you'll see why this is handy in a bit. 3. Note that the right hand side of the replacement rules are not in the simplest forms possible. :[font = subsection; inactive; preserveAspect] Step 8 - What MMA command do you think might simplify algebraic equations? Find it, describe it, and apply it to soln. ;[s] 3:0,0;115,1;119,0;121,-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 8 :[font = special1; inactive; preserveAspect; endGroup] 1. Simplify[] can take lots of time to produce its result. Why might this be the case? 2. You could have applied Simplify[] to begin with using the nested property of functions. Or you could also go back and edit; the editing is especially easy if you use postfix notation for functions. ;[s] 5:0,0;4,1;15,0;117,1;127,0;295,-1; 2:3,16,12,Times,0,14,0,0,0;2,15,11,Courier,0,14,0,0,0; :[font = subsection; inactive; preserveAspect] Step 9 - Find out about the postfix notation in Wolfram and use it to apply Simplify[] to your result in Step 7. ;[s] 3:0,0;77,1;87,0;115,-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. There are other commands that do partial simplication: Expand[], Factor[], Together[], Apart[], Cancel[], and Collect[]. You might want to use these commands, if possible, because they take less time than Simplify[]. ;[s] 15:0,0;59,1;67,0;70,1;78,0;81,1;91,0;94,1;101,0;104,1;112,0;120,1;131,0;216,1;226,0;228,-1; 2:8,16,12,Times,0,14,0,0,0;7,15,11,Courier,0,14,0,0,0; :[font = subsection; inactive; preserveAspect; startGroup] Step 10 - Now, as illustrated in the next cell, you can evaluate v[to] by using replacement rules. Look over the code and then activate the cell. :[font = input; preserveAspect; endGroup] v[xo, vo, to, g] /. {to -> (vo + Sqrt[vo^2 + 2*g*xo])/g} :[font = subsection; inactive; preserveAspect; startGroup] Comment 10 :[font = special1; inactive; preserveAspect; endGroup] 1. It's painful to type in all that stuff on the right hand side. You might expect that there's a way to get the replacement rule directly from soln. ;[s] 3:0,0;147,1;151,0;155,-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 11 - Type in the following and describe what results. :[font = special3; inactive; preserveAspect; endGroup] soln soln[[2]] soln[[2,1]] soln[[2,1,2]] :[font = subsection; inactive; preserveAspect; startGroup] Comment 11 :[font = special1; inactive; preserveAspect; endGroup] 1. If you're confused, try FullForm[] on the four expressions for soln given above. 2. The double bracket notation is used to find parts of lists or expressions. 3. The notation is equivalent to the MMA command Part[]. Get help on Part[]. 4. Note it's usefulness if you want to find an expression for the time to. All you have to do is set the time to equal to soln[[2,1,2]]. ;[s] 11:0,0;29,1;39,0;70,1;74,0;219,1;225,0;241,1;247,0;377,1;390,0;392,-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 12 - Now find v[to] for the two values of to using soln[[1]] and soln[[2]]. Simplify the results using postfix notation. ;[s] 5:0,0;61,1;70,0;77,1;86,0;134,-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 13 - Try applying soln directly as a replacement rule in Step 10. What do you find? ;[s] 3:0,0;25,1;29,0;94,-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 13 :[font = special1; inactive; preserveAspect; endGroup] 1. Do you now see why results of solutions of equations are given in terms of rules? :[font = subsection; inactive; preserveAspect] Step 14 - If you didn't want to use replacement rules, you could set to = soln[[1,1,2]] and then plug to directly into the velocity function. Try this out. ;[s] 5:0,0;71,1;89,0;106,1;108,0;162,-1; 2:3,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0; :[font = subsection; inactive; preserveAspect; endGroup] Step 15 - Create a function that determines the final speed of the ball as a function of vo, xo, and g. Then use it to plot the final speed as a function of vo when xo is 100 and vo goes from -100 to 100. :[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 myEx07. ;[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; ^*)