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

Iterating Solutions

One important use of NDSolve`StateData objects is to have more control of the integration. For some problems, it is appropriate to check the solution and start over or change parameters depending on certain conditions.

Iterating solutions to differential equations.

This creates an NDSolve`StateData object that contains the information needed to solve the equation for an oscillator with a varying coefficient using an explicit Runge-Kutta method.

In[4]:= 

Out[4]=

Note that when you use NDSolve`ProcessEquations, you do not need to give the range of the t variable explicitly because that information is not needed to set up the equations in a form ready to solve. (For PDEs, you do have to give the ranges of all spatial variables, however, since that information is essential for determining an appropriate discretization.)

This computes the solution out to time t = 1.

In[5]:= 

NDSolve`Iterate does not return a value because it modifies the NDSolve`StateData object assigned to the variable state. Thus, the command affects the value of the variable in a manner similar to setting parts of a list, as described in Section 2.4.2 of The Mathematica Book. You can see that the value of state has changed since it now displays the current time to which it is integrated.

The output form of state shows the range of times over which the solution has been integrated.

In[6]:= 

Out[6]=

If you want to integrate further, you can call NDSolve`Iterate again, but with a larger value for time.

This computes the solution out to time t = 3.

In[7]:= 

You can specify a time that is earlier than the first current time, in which case the integration proceeds backwards with respect to time.

This computes the solution from the initial condition backwards to t = -Pi/2.

In[8]:= 

NDSolve`Iterate allows you to specify intermediate times at which to stop. This can be useful, for example, to avoid discontinuities. Typically, this strategy is more effective with so-called one-step methods, such as the explicit Runge-Kutta method used in this example. However, it generally works with the default NDSolve method as well.

This computes the solution out to t = 10Pi, making sure that the solution does not have problems with the points of discontinuity in the coefficients at t = Pi, 2 Pi, ....

In[9]:= 


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: