Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

InterpolatingFunctionAnatomy

NDSolve returns solutions as InterpolatingFunction objects. Most of the time, simply using these as functions does what is needed, but occasionally it is useful to access the data inside, which includes the actual values and points NDSolve computed when taking steps. The exact structure of an InterpolatingFunction object is arranged to make the data storage efficient and evaluation at a given point fast. This structure may change between Mathematica versions, so code which is written in terms of accessing parts of InterpolatingFunction objects may not work with new versions of Mathematica. The DifferentialEquations`InterpolatingFunctionAnatomy` package provides an interface to the data in an InterpolatingFunction object which will be maintained for future Mathematica versions.

Anatomy of InterpolatingFunction objects.

This loads the package.

In[1]:= 

One common situation where the InterpolatingFunctionAnatomy package is useful is when NDSolve cannot compute a solution over the full range of values that you specified, and you want to plot all of the solution which was computed to try to understand better when might have gone wrong.

Here is an example of a differential equation which cannot be computed up to the specified endpoint.

In[2]:= 

Out[2]=

This gets the domain.

In[3]:= 

Out[3]=

Once the domain has been returned in a list, it is easy to use Part to get the desired endpoints and make the plot.

In[4]:= 

Out[5]=

From the plot, it is quite apparent that a singularity has formed and it will not be possible to integrate the system any further.

Sometimes it is useful to see where NDSolve took steps. Getting the coordinates is useful for doing this.

This shows the values which NDSolve computed at each step it took. It is quite apparent from this that nearly all of the steps were used to try to resolve the singularity.

In[6]:= 

Out[7]=

The package is particularly useful for analyzing the computed solutions of PDEs

With this initial condition, Burgers' equation forms a steep front.

In[8]:= 

Out[8]=

This shows the number of points used in each dimension.

In[9]:= 

Out[9]=

This shows the interpolation order used in each dimension.

In[10]:= 

Out[10]=

This shows that the inability to resolve the front has manifested itself as numerical instability.

In[11]:= 

Out[11]=

This shows the values computed at the spatial grid points at the endpoint of the temporal integration.

In[12]:= 

Out[14]=

It is easily seen from the point plot above that the front has not been resolved.

This makes a 3-D plot showing how the time evolution for each of the spatial grid points. The initial condition is shown in red.

In[15]:= 

Out[15]=

When a derivative is taken of an InterpolatingFunction object, a new InterpolatingFunction object is returned which gives the requested derivative when evaluated at a point. The InterpolatingFunctionDerivativeOrder is a way of determining what derivative will be evaluated.

The derivative returns a new InterpolatingFunction object.

In[16]:= 

Out[16]=

This shows what derivative will be evaluated.

In[17]:= 

Out[17]=


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: