This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
How to | Check the Results of NDSolve
For most differential equations, the results given by NDSolve are quite accurate. However, because its results are based on numerical sampling and error estimates, there can occasionally be significant errors. When you need to be sure of the quality of a solution, it is a good idea to do some basic checking of the solution.
Comparing a solution computed with WorkingPrecision higher than the default MachinePrecision is often a useful way to check results.
Different solutions may save solution data at different points, leading to differences at these points. To keep these differences no larger than the numerical error in the solution, use InterpolationOrder All.
Use NDSolve with the default MachinePrecision to compute the solution:
Use NDSolve with WorkingPrecision to compute the solution:
Since errors are often quite small, it is useful to view them on a logarithmic scale. RealExponent is effectively equal to Log10, but without a singularity at zero, so it is a good choice for viewing differences that might be zero at some points:
 Out[3]=
The residual for a differential equation is the difference of its left and right sides:
The numerical methods used in NDSolve are designed to keep the residual small at any point. You can plot the logs of the residuals:
 Out[5]=
As you can see, the numerical errors are significantly smaller when using the higher WorkingPrecision. The tradeoff is, of course, increased calculation time.
Although in most cases keeping the residual small leads to an accurate numerical solution, this is not always true. A simple example is the Duffing equation:
 Out[8]=