Example 10
Symbolic and Numerical Solutions to Differential Equations I

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

Topics and Skills

1.  DSolve[].
2.  Brief mention of anonymous functions.
3.  NDSolve[].
4.  InterpolatingFunction[].  
5.  Short[].

Problem

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.

The relevant equations:   dv/dt  =  g  -  bv     and     b  =  c/m .

Step 1 - The MMA command that symbolically solve differential equations (DEQ) is  DSolve[].  What can you find out about this command?

Comment 1

1.  Make sure you look at the options for  DSolve[].

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.

Clear[v, b, g, soln1]
soln1 = DSolve[v'[t] + b v[t] - g == 0, v[t], t]

Comment 2

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

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.

Comment 3

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

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.

Comment 4

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.

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]] ?)

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.

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.

Comment 7

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?

Step 8 - What do you think is the MMA command for numerically solving DEQs?  Find out.

Comment 8

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

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.

Comment 9

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.

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.

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

Comment 11

1.  What happens if you didn't set  PlotRange  to  All?  Try it.

Save Your Notebook

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