Stiffness - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Numerical Solution of Stiff IVPs in Maple

 

Description

Examples

References

Description

• 

If it takes too long to solve an initial value problem (IVP) with the default numerical solver rkf45 or ck45 or with the default 'adamsfunc' option in lsode, then the IVP might be "stiff". A stiff IVP can be solved efficiently with either the default solver using the 'stiff=true' option (rosenbrock) or any of the `back-' options in lsode.

• 

rosenbrock is intended for modest accuracy, so by default it uses a relative tolerance of 11000.  You should use lsode if you need high accuracy.  By default it uses a relative tolerance of 110000000. Numerical methods for stiff IVPs must form partial derivatives.  rosenbrock does this analytically, but if this is not possible, you can use lsode because it approximates them with finite differences.

• 

Stiffness is complicated because it involves both the IVP and the method used to solve it. A stiff IVP has a solution that is very stable (some solutions that start near it converge to it very quickly) and is slowly varying (other solutions change on much faster time scales). Special methods allow stiff problems to be solved efficiently, but they can be very inefficient for problems that are not stiff.

• 

Unless you have reason to believe your IVP is stiff, you should try a method for nonstiff problems first, such as the default method of dsolve[numeric] or lsode with its default option.  If that proves unsatisfactory, try the option 'stiff=true' in the call to dsolve[numeric], which invokes a Rosenbrock method. You might also try the one of the 'back-' options of lsode, which invoke backward differentiation methods (BDFs, also known as Gear's method).

Examples

A simple example of a stiff linear IVP:

deq1diffyt,t+10000ytcost=sint

deq1ⅆⅆtyt+10000yt10000cost=sint

(1)

ic1y0=2

ic1y0=2

(2)

dsol1dsolvedeq1,ic1,numeric,range=0..10,stiff=true

dsol1procx_rosenbrock...end proc

(3)

dsol110.0

t=10.0,yt=−0.839071537030767

(4)

cos10.0

−0.8390715291

(5)

Issue the following command to see a plot of the solution.

plotsodeplotdsol1,t,yt

Trying to solve this IVP with the stiff=false option is too expensive. From the general solution of this equation, cost+_C1ⅇ10000t, we see that the solution of the IVP is very stable because all solutions come together exponentially fast.  And, after an initial transient, the solution of the IVP approaches the slowly varying solution cost.

We can solve this same example with the backfull option for lsode, which by default asks for more accuracy than rosenbrock.

dsol2dsolvedeq1,ic1,numeric,method=lsodebackfull

dsol2procx_lsode...end proc

(6)

dsol210.0

t=10.0,yt=−0.839071701470174

(7)

cos10.0

−0.8390715291

(8)

The van der Pol equation in relaxation oscillation is a famous example of a stiff nonlinear problem.

μ1000

μ1000

(9)

deq3diffyx,x,xμ1yx2diffyx,x+yx=0

deq3ⅆ2ⅆx2yx10001yx2ⅆⅆxyx+yx=0

(10)

ic3y0=2,Dy0=0

ic3y0=2,Dy0=0

(11)

dsol3dsolvedeq3unionic3,numeric,range=0..3000,stiff=true

dsol3procx_rosenbrock...end proc

(12)

Issue the following command to see a plot of the solution that shows regions of sharp change.

plotsodeplotdsol3,x,yx

If you experiment with other initial conditions, you will see that all non-trivial solutions converge very rapidly to this limit cycle.  The IVP is stiff where the solution is slowly varying.

A stiff nonlinear system from reactor kinetics:

deq4diffut,t=0.011+ut+1000ut+10.01+ut+vt,diffvt,t=0.011+vt20.01+ut+vt

deq4ⅆⅆtut=0.011+ut+1000ut+10.01+ut+vt,ⅆⅆtvt=0.011+vt20.01+ut+vt

(13)

ic4u0=0,v0=0:

dsol4dsolvedeq4,ic4,numeric,method=rosenbrock,range=0..20

dsol4procx_rosenbrock...end proc

(14)

plotsodeplotdsol4,t,ut,vt

References

  

Gear, C. W. Numerical Initial Value Problems in Ordinary Differential Equations. Prentice Hall, 1971.

  

Hairer, E., and Wanner, G. Solving Ordinary Differential Equations II, Stiff and Differential-Algebraic Problems. Springer, 1996.

  

Shampine, L. F., and Corless, R. M. "Initial Value Problems for ODEs in Problem Solving Environments." Journal of Computational and Applied Mathematics, Vol. 125 (2000): 31-40.

See Also

dsolve/Error_Control

dsolve[lsode]

dsolve[numeric,IVP]

dsolve[numeric]

dsolve[rosenbrock]