Numeric approxiamtions

Sometimes, Mathematica can't solve a differential equation (if it is evil enough). Or, it might take a very long time for it to solve and you might not really have any need for a complete symbolic solution.  Often, a good numerical approximation is all you really need.  In Mathematica, you you NDSolve (Numeric DSolve) to compute these.  One of the nice things about the way Mathematica does this is that it doesn't just give you a numeric resulet (i.e., [Graphics:../Images/index_gr_65.gif]), it gives you a numerical "interpolating function" which you can then use to compute the value of the function at any point in your computed domain.  Thus, you can graph this solution, find its intercepts, etc.  Not surprisingly, you must provide enough initial conditions to make sure that the solution is unique (i.e., no unknown constants).

Let's solve the following differential equation:  [Graphics:../Images/index_gr_66.gif] (remember that [Graphics:../Images/index_gr_67.gif] means the 3rd derivative), where [Graphics:../Images/index_gr_68.gif].  We must also specify a domain over which we want the solution to be valid, say [Graphics:../Images/index_gr_69.gif].

[Graphics:../Images/index_gr_70.gif]
[Graphics:../Images/index_gr_71.gif]
[Graphics:../Images/index_gr_72.gif]
[Graphics:../Images/index_gr_73.gif]
[Graphics:../Images/index_gr_74.gif]
[Graphics:../Images/index_gr_75.gif]

[Graphics:../Images/index_gr_76.gif]

[Graphics:../Images/index_gr_77.gif]

If you need greater accuracy in your approximation, you can set the WorkingPrecision to be higher (actually, if you really want to investigate this in more detail, you should read up on WorkingPrecision, PrecisionGoal, and AccuracyGoal in the online help; it can get a bit complicated - setting WorkingPrecision to a large number will often help, however).  The following does all internal computations to an internal accuracy of 30 digits (so your answer is probably accurate to about 20 digits):

[Graphics:../Images/index_gr_78.gif]
[Graphics:../Images/index_gr_79.gif]

It's a bit trickier here if you want to graph one of these for a variety of initial conditions:

[Graphics:../Images/index_gr_80.gif]
[Graphics:../Images/index_gr_81.gif]
[Graphics:../Images/index_gr_82.gif]

[Graphics:../Images/index_gr_83.gif]

[Graphics:../Images/index_gr_84.gif]

If you want to solve for multiple initial conditions (like above) or for different values of a parameter, the important thing to remember is that NDSolve will not work with unknown constants in it (unlike DSolve), so you have to plug those constants in multiple times (using the Table command like I did above is a good way to do this).  (You could actually approach DSolve the same way if you wish, but if the differential equation takes a long time to solve, it could really add up to a long solution time in that case).


Converted by Mathematica      July 20, 2003