# How to | Plot the Results of NDSolve

NDSolve solves a differential equation numerically. It returns solutions in a form that can be readily used in many different ways. One typical use would be to produce a plot of the solution.

As an example, take the equation with the initial conditions and :

In NDSolve, make the equation the first argument, the function to solve for, , the second argument, and the range for the independent variable the third argument:

Out[2]= | |

This plots the solution:

Out[3]= | |

It is common to plot the solution along with its derivative (or more than one dependent variable). To see them in different colors use an Evaluate around what you want to be plotted:

Out[4]= | |

For systems with two and three degrees of freedom, a plot in the phase plane is often more illuminating. You can do this using ParametricPlot:

Out[5]= | |

It is easy to use a phase plane plot with Manipulate to allow you to vary initial conditions:

The Locator input allows you to drag the point to change initial conditions. The parameter allows you to control the interval over which the problem is solved.

For a partial differential equation there are often several choices. For an example, consider Wolfram's nonlinear wave equation [more info]:

Out[7]= | |

A good way to get an overall view of the solution is to use Plot3D:

Out[8]= | |

An alternative that often gives good information about solution details is DensityPlot:

Out[9]= | |

For time evolution equations like this, often the best intuition comes from an animation. Typically you will get the best results using ListAnimate. First make a list of plots at equal time intervals apart, all with the same PlotRange:

Now animate the list:

Out[11]= | |

In this case it is a little hard to see the wave motion because of the varying background coming from a zero initial condition. An easy way to eliminate this is to solve the ODE corresponding to that and subtract it out:

Out[12]= | |

Out[14]= | |