Example 07
Symbolic Integration, Differentiation, 
and Equation Solving

Copyright „ 1993 by Bill Titus, Carleton College, 
Department of Physics and Astronomy, Northfield, MN  55057-4025
September 6, 1993

Topics and Skills

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.

Problem

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.

Recall that the equations for definite integration are:

v[t] = v[0] + Ú ot a[s] ds
	 x[t] = x[0] + Ú ot v[s] ds

Step 1 - What do you think is the MMA command for integration?  Find out.

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.

Comment 2

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.

Step 3 -  Not surprisingly, MMA has a command  D[]  which take the derivative of a function.  Find out about this command.

Step 4 - Apply what you found in Step 3 to determine the derivatives of  sin[x],  x3,  and  tanh[sin[z2]].

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.

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 +

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.

Comment 6

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.

Step 7 - Solve your position equation for  to  and name the output  soln.  Describe the form in which   soln  appears.

Comment 7

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.

Step 8 - What MMA command do you think might simplify algebraic equations?  Find it, describe it, and apply it to  soln.

Comment 8

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.

Step 9 - Find out about the postfix notation in Wolfram and use it to apply  Simplify[]  to your result in Step 7.

Comment 9

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[].

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.

v[xo, vo, to, g] /.
    {to -> (vo + Sqrt[vo^2 + 2*g*xo])/g}

Comment 10

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.

Step 11 - Type in the following and describe what results.

soln
	soln[[2]]
	soln[[2,1]]
	soln[[2,1,2]]

Comment 11

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]].

Step 12 - Now find  v[to]  for the two values of  to  using  soln[[1]]  and  soln[[2]].  Simplify the results using postfix notation.

Step 13 - Try applying   soln   directly as a replacement rule in Step 10.  What do you find?

Comment 13

1.  Do you now see why results of solutions of equations are given in terms of rules?

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.

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.

Save Your Notebook

Remove any output cells from this notebook and then use  Save As  to store your notebook under the name  myEx07.