D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02NCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D02NCF is a forward communication routine for integrating stiff systems of explicit ordinary differential equations when the Jacobian is a banded matrix.

## 2  Specification

 SUBROUTINE D02NCF ( NEQ, LDYSAV, T, TOUT, Y, YDOT, RWORK, RTOL, ATOL, ITOL, INFORM, FCN, YSAV, SDYSAV, JAC, WKJAC, NWKJAC, JACPVT, NJCPVT, MONITR, ITASK, ITRACE, IFAIL)
 INTEGER NEQ, LDYSAV, ITOL, INFORM(23), SDYSAV, NWKJAC, JACPVT(NJCPVT), NJCPVT, ITASK, ITRACE, IFAIL REAL (KIND=nag_wp) T, TOUT, Y(NEQ), YDOT(NEQ), RWORK(50+4*NEQ), RTOL(*), ATOL(*), YSAV(LDYSAV,SDYSAV), WKJAC(NWKJAC) EXTERNAL FCN, JAC, MONITR

## 3  Description

D02NCF is a general purpose routine for integrating the initial value problem for a stiff system of explicit ordinary differential equations,
 $y′=gt,y.$
It is designed specifically for the case where the Jacobian $\frac{\partial g}{\partial y}$ is a banded matrix.
Both interval and step oriented modes of operation are available and also modes designed to permit intermediate output within an interval oriented mode.
An outline of a typical calling program for D02NCF is given below. It calls the banded matrix linear algebra setup routine D02NTF, the Backward Differentiation Formula (BDF) integrator setup routine D02NVF, and its diagnostic counterpart D02NYF.
!     Declarations

EXTERNAL FCN, JAC, MONITR
.
.
.
IFAIL = 0
CALL D02NVF(...,IFAIL)
CALL D02NTF(NEQ, NEQMAX, JCEVAL, ML, MU, NWKJAC, NJCPVT, &
RWORK, IFAIL)
IFAIL = -1
CALL D02NCF(NEQ, NEQMAX, T, TOUT, Y, YDOT, RWORK, RTOL,  &
ATOL, ITOL, INFORM, FCN, YSAVE, NY2DIM, JAC, &
WKJAC, NWKJAC,JACPVT, NJCPVT, MONITR, ITASK, &
ITRACE, IFAIL)
IF (IFAIL.EQ.1 .OR. IFAIL.GE.14) STOP
IFAIL = 0
CALL D02NYF(...)
.
.
.
STOP
END
The linear algebra setup routine D02NTF and one of the integrator setup routines, D02NVF or D02NWF, must be called prior to the call of D02NCF. The integrator diagnostic routine D02NYF may be called after the call to D02NCF. There is also a routine, D02NZF, designed to permit you to change step size on a continuation call to D02NCF without restarting the integration process.

## 4  References

See the D02M–N sub-chapter Introduction.

## 5  Parameters

1:     NEQ – INTEGERInput
On entry: the number of differential equations to be solved.
Constraint: ${\mathbf{NEQ}}\ge 1$.
2:     LDYSAV – INTEGERInput
On entry: a bound on the maximum number of differential equations to be solved during the integration.
Constraint: ${\mathbf{LDYSAV}}\ge {\mathbf{NEQ}}$.
3:     T – REAL (KIND=nag_wp)Input/Output
On entry: $t$, the value of the independent variable. The input value of T is used only on the first call as the initial point of the integration.
On exit: the value at which the computed solution $y$ is returned (usually at TOUT).
4:     TOUT – REAL (KIND=nag_wp)Input
On entry: the next value of $t$ at which a computed solution is desired. For the initial $t$, the input value of TOUT is used to determine the direction of integration. Integration is permitted in either direction (see also ITASK).
Constraint: ${\mathbf{TOUT}}\ne {\mathbf{T}}$.
5:     Y(NEQ) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the values of the dependent variables (solution). On the first call the first NEQ elements of Y must contain the vector of initial values.
On exit: the computed solution vector, evaluated at T (usually ${\mathbf{T}}={\mathbf{TOUT}}$).
6:     YDOT(NEQ) – REAL (KIND=nag_wp) arrayOutput
On exit: the time derivatives ${y}^{\prime }$ of the vector $y$ at the last integration point.
7:     RWORK($50+4×{\mathbf{NEQ}}$) – REAL (KIND=nag_wp) arrayCommunication Array
8:     RTOL($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array RTOL must be at least $1$ if ${\mathbf{ITOL}}=1$ or $2$, and at least ${\mathbf{NEQ}}$ otherwise.
On entry: the relative local error tolerance.
Constraint: ${\mathbf{RTOL}}\left(i\right)\ge 0.0$ for all relevant $i$ (see ITOL).
9:     ATOL($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array ATOL must be at least $1$ if ${\mathbf{ITOL}}=1$ or $3$, and at least ${\mathbf{NEQ}}$ otherwise.
On entry: the absolute local error tolerance.
Constraint: ${\mathbf{ATOL}}\left(i\right)\ge 0.0$ for all relevant $i$ (see ITOL).
10:   ITOL – INTEGERInput
On entry: a value to indicate the form of the local error test. ITOL indicates to D02NCF whether to interpret either or both of RTOL or ATOL as a vector or a scalar. The error test to be satisfied is $‖{e}_{i}/{w}_{i}‖<1.0$, where ${w}_{i}$ is defined as follows:
 ITOL RTOL ATOL ${w}_{i}$ 1 scalar scalar ${\mathbf{RTOL}}\left(1\right)×\left|{y}_{i}\right|+{\mathbf{ATOL}}\left(1\right)$ 2 scalar vector ${\mathbf{RTOL}}\left(1\right)×\left|{y}_{i}\right|+{\mathbf{ATOL}}\left(i\right)$ 3 vector scalar ${\mathbf{RTOL}}\left(i\right)×\left|{y}_{i}\right|+{\mathbf{ATOL}}\left(1\right)$ 4 vector vector ${\mathbf{RTOL}}\left(i\right)×\left|{y}_{i}\right|+{\mathbf{ATOL}}\left(i\right)$
${e}_{i}$ is an estimate of the local error in ${y}_{i}$, computed internally, and the choice of norm to be used is defined by a previous call to an integrator setup routine.
Constraint: ${\mathbf{ITOL}}=1$, $2$, $3$ or $4$.
11:   INFORM($23$) – INTEGER arrayCommunication Array
12:   FCN – SUBROUTINE, supplied by the user.External Procedure
FCN must evaluate the derivative vector for the explicit ordinary differential equation system, defined by ${y}^{\prime }=g\left(t,y\right)$.
The specification of FCN is:
 SUBROUTINE FCN ( NEQ, T, Y, F, IRES)
 INTEGER NEQ, IRES REAL (KIND=nag_wp) T, Y(NEQ), F(NEQ)
1:     NEQ – INTEGERInput
On entry: the number of differential equations being solved.
2:     T – REAL (KIND=nag_wp)Input
On entry: $t$, the current value of the independent variable.
3:     Y(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: the value of ${y}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$.
4:     F(NEQ) – REAL (KIND=nag_wp) arrayOutput
On exit: the value ${y}_{\mathit{i}}^{\prime }$, given by ${y}_{\mathit{i}}^{\prime }={g}_{\mathit{i}}\left(t,y\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$.
5:     IRES – INTEGERInput/Output
On entry: ${\mathbf{IRES}}=1$.
On exit: you may set IRES as follows to indicate certain conditions in FCN to the integrator:
${\mathbf{IRES}}=1$
Indicates a normal return from FCN, that is IRES has not been altered by you and integration continues.
${\mathbf{IRES}}=2$
Indicates to the integrator that control should be passed back immediately to the calling (sub)program with the error indicator set to ${\mathbf{IFAIL}}={\mathbf{11}}$.
${\mathbf{IRES}}=3$
Indicates to the integrator that an error condition has occurred in the solution vector, its time derivative or in the value of $t$. The integrator will use a smaller time step to try to avoid this condition. If this is not possible the integrator returns to the calling (sub)program with the error indicator set to ${\mathbf{IFAIL}}={\mathbf{7}}$.
${\mathbf{IRES}}=4$
Indicates to the integrator to stop its current operation and to enter MONITR immediately with parameter ${\mathbf{IMON}}=-2$.
FCN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02NCF is called. Parameters denoted as Input must not be changed by this procedure.
13:   YSAV(LDYSAV,SDYSAV) – REAL (KIND=nag_wp) arrayCommunication Array
14:   SDYSAV – INTEGERInput
On entry: the second dimension of the array YSAV as declared in the (sub)program from which D02NCF is called. An appropriate value for SDYSAV is described in the specification of the integrator setup routines D02NVF and D02NWF. This value must be the same as that supplied to the integrator setup routine.
15:   JAC – SUBROUTINE, supplied by the NAG Library or the user.External Procedure
JAC must evaluate the Jacobian of the system. If this option is not required, the actual argument for JAC must be the dummy routine D02NCZ. (D02NCZ is included in the NAG Library.) You must indicate to the integrator whether this option is to be used by setting the parameter JCEVAL appropriately in a call to the banded linear algebra setup routine D02NTF.
First we must define the system of nonlinear equations which is solved internally by the integrator. The time derivative, ${y}^{\prime }$, generated internally, has the form
 $y′ = y-z / hd ,$
where $h$ is the current step size and $d$ is a parameter that depends on the integration method in use. The vector $y$ is the current solution and the vector $z$ depends on information from previous time steps. This means that $\frac{d}{d{y}^{\prime }}\left(\text{​ ​}\right)=\left(hd\right)\frac{d}{dy}\left(\text{​ ​}\right)$. The system of nonlinear equations that is solved has the form
 $y′ - g t,y = 0$
but it is solved in the form
 $r t,y = 0 ,$
where $r$ is the function defined by
 $r t,y =hd y-z / hd - g t,y .$
It is the Jacobian matrix $\frac{\partial r}{\partial y}$ that you must supply in JAC as follows:
 $∂ri ∂yj =1-hd ∂gi ∂yj , if ​i=j, ∂ri ∂yj = -hd ∂gi ∂yj , otherwise.$
The specification of JAC is:
 SUBROUTINE JAC ( NEQ, T, Y, H, D, ML, MU, P)
 INTEGER NEQ, ML, MU REAL (KIND=nag_wp) T, Y(NEQ), H, D, P(ML+MU+1,NEQ)
1:     NEQ – INTEGERInput
On entry: the number of differential equations being solved.
2:     T – REAL (KIND=nag_wp)Input
On entry: $t$, the current value of the independent variable.
3:     Y(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: ${y}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$, the current solution component.
4:     H – REAL (KIND=nag_wp)Input
On entry: the current step size.
5:     D – REAL (KIND=nag_wp)Input
On entry: the parameter $d$ which depends on the integration method.
6:     ML – INTEGERInput
7:     MU – INTEGERInput
On entry: the number of subdiagonals and superdiagonals respectively in the band.
8:     P(${\mathbf{ML}}+{\mathbf{MU}}+1$,NEQ) – REAL (KIND=nag_wp) arrayInput/Output
On entry: is set to zero.
On exit: elements of the Jacobian matrix $\frac{\partial r}{\partial y}$ stored as specified by the following pseudocode:
DO 20 I = 1, NEQ J1 = MAX(I-ML,1) J2 = MIN(I+MU,NEQ) DO 10 J = J1, J2 K = MIN(ML+1-I,0)+J P(K,I) = δR/δY(I,J) 10 CONTINUE 20 CONTINUE
Only nonzero elements of this array need be set, since it is preset to zero before the call to JAC.
JAC must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02NCF is called. Parameters denoted as Input must not be changed by this procedure.
16:   WKJAC(NWKJAC) – REAL (KIND=nag_wp) arrayCommunication Array
17:   NWKJAC – INTEGERInput
On entry: the dimension of the array WKJAC as declared in the (sub)program from which D02NCF is called. This value must be the same as that supplied to the linear algebra setup routine D02NTF.
Constraint: ${\mathbf{NWKJAC}}\ge \left(2{m}_{L}+{m}_{U}+1\right)×{\mathbf{NEQ}}$, where ${m}_{L}$ and ${m}_{U}$ are the number of subdiagonals and superdiagonals respectively in the band, defined by a call to D02NTF.
18:   JACPVT(NJCPVT) – INTEGER arrayCommunication Array
19:   NJCPVT – INTEGERInput
On entry: the dimension of the array JACPVT as declared in the (sub)program from which D02NCF is called. This value must be the same as that supplied to the linear algebra setup routine D02NTF.
Constraint: ${\mathbf{NJCPVT}}\ge {\mathbf{LDYSAV}}$.
20:   MONITR – SUBROUTINE, supplied by the NAG Library or the user.External Procedure
MONITR performs tasks requested by you. If this option is not required, then the actual argument for MONITR must be the dummy routine D02NBY. (D02NBY is included in the NAG Library.)
The specification of MONITR is:
 SUBROUTINE MONITR ( NEQ, LDYSAV, T, HLAST, HNEXT, Y, YDOT, YSAV, R, ACOR, IMON, INLN, HMIN, HMAX, NQU)
 INTEGER NEQ, LDYSAV, IMON, INLN, NQU REAL (KIND=nag_wp) T, HLAST, HNEXT, Y(NEQ), YDOT(NEQ), YSAV(LDYSAV,$\mathit{sdysav}$), R(NEQ), ACOR(NEQ,2), HMIN, HMAX
where $\mathit{sdysav}$ is the numerical value of SDYSAV in the call of D02NCF.
1:     NEQ – INTEGERInput
On entry: the number of differential equations being solved.
2:     LDYSAV – INTEGERInput
On entry: an upper bound on the number of differential equations to be solved.
3:     T – REAL (KIND=nag_wp)Input
On entry: the current value of the independent variable.
4:     HLAST – REAL (KIND=nag_wp)Input
On entry: the last step size successfully used by the integrator.
5:     HNEXT – REAL (KIND=nag_wp)Input/Output
On entry: the step size that the integrator proposes to take on the next step.
On exit: the next step size to be used. If this is different from the input value, then IMON must be set to $4$.
6:     Y(NEQ) – REAL (KIND=nag_wp) arrayInput/Output
On entry: $y$, the values of the dependent variables evaluated at $t$.
On exit: these values must not be changed unless IMON is set to $2$.
7:     YDOT(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: the time derivatives ${y}^{\prime }$ of the vector $y$.
8:     YSAV(LDYSAV,$\mathit{sdysav}$) – REAL (KIND=nag_wp) arrayInput
On entry: workspace to enable you to carry out interpolation using either of the routines D02XJF or D02XKF.
9:     R(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{IMON}}=0$ and ${\mathbf{INLN}}=3$, the first NEQ elements contain the residual vector, ${y}^{\prime }-g\left(t,y\right)$.
10:   ACOR(NEQ,$2$) – REAL (KIND=nag_wp) arrayInput
On entry: with ${\mathbf{IMON}}=1$, ${\mathbf{ACOR}}\left(i,1\right)$ contains the weight used for the $i$th equation when the norm is evaluated, and ${\mathbf{ACOR}}\left(i,2\right)$ contains the estimated local error for the $i$th equation. The scaled local error at the end of a timestep may be obtained by calling the real function D02ZAF as follows:
IFAIL = 1 ERRLOC = D02ZAF(NEQ, ACOR(1,2), ACOR(1,1), IFAIL) ! CHECK IFAIL BEFORE PROCEEDING
11:   IMON – INTEGERInput/Output
On entry: a flag indicating under what circumstances MONITR was called:
${\mathbf{IMON}}=-2$
Entry from the integrator after ${\mathbf{IRES}}=4$ (set in FCN) caused an early termination (this facility could be used to locate discontinuities).
${\mathbf{IMON}}=-1$
The current step failed repeatedly.
${\mathbf{IMON}}=0$
Entry after a call to the internal nonlinear equation solver (see INLN).
${\mathbf{IMON}}=1$
The current step was successful.
On exit: may be reset to determine subsequent action in D02NCF.
${\mathbf{IMON}}=-2$
Integration is to be halted. A return will be made from the integrator to the calling (sub)program with ${\mathbf{IFAIL}}={\mathbf{12}}$.
${\mathbf{IMON}}=-1$
Allow the integrator to continue with its own internal strategy. The integrator will try up to three restarts unless IMON is set $\text{}\ne -1$ on exit.
${\mathbf{IMON}}=0$
Return to the internal nonlinear equation solver, where the action taken is determined by the value of INLN (see INLN).
${\mathbf{IMON}}=1$
Normal exit to the integrator to continue integration.
${\mathbf{IMON}}=2$
Restart the integration at the current time point. The integrator will restart from order $1$ when this option is used. The solution Y, provided by MONITR, will be used for the initial conditions.
${\mathbf{IMON}}=3$
Try to continue with the same step size and order as was to be used before the call to MONITR. HMIN and HMAX may be altered if desired.
${\mathbf{IMON}}=4$
Continue the integration but using a new value of HNEXT and possibly new values of HMIN and HMAX.
12:   INLN – INTEGEROutput
On exit: the action to be taken by the internal nonlinear equation solver when MONITR is exited with ${\mathbf{IMON}}=0$. By setting ${\mathbf{INLN}}=3$ and returning to the integrator, the residual vector is evaluated and placed in the array R, and then MONITR is called again. At present this is the only option available: INLN must not be set to any other value.
13:   HMIN – REAL (KIND=nag_wp)Input/Output
On entry: the minimum step size to be taken on the next step.
On exit: the minimum step size to be used. If this is different from the input value, then IMON must be set to $3$ or $4$.
14:   HMAX – REAL (KIND=nag_wp)Input/Output
On entry: the maximum step size to be taken on the next step.
On exit: the maximum step size to be used. If this is different from the input value, then IMON must be set to $3$ or $4$. If HMAX is set to zero, no limit is assumed.
15:   NQU – INTEGERInput
On entry: the order of the integrator used on the last step. This is supplied to enable you to carry out interpolation using either of the routines D02XJF or D02XKF.
MONITR must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02NCF is called. Parameters denoted as Input must not be changed by this procedure.
On entry: the task to be performed by the integrator.
${\mathbf{ITASK}}=1$
Normal computation of output values of $y\left(t\right)$ at $t={\mathbf{TOUT}}$ (by overshooting and interpolating).
${\mathbf{ITASK}}=2$
Take one step only and return.
${\mathbf{ITASK}}=3$
Stop at the first internal integration point at or beyond $t={\mathbf{TOUT}}$ and return.
${\mathbf{ITASK}}=4$
Normal computation of output values of $y\left(t\right)$ at $t={\mathbf{TOUT}}$ but without overshooting $t={\mathbf{TCRIT}}$. TCRIT must be specified as an option in one of the integrator setup routines before the first call to the integrator, or specified in the optional input routine before a continuation call. TCRIT may be equal to or beyond TOUT, but not before it, in the direction of integration.
${\mathbf{ITASK}}=5$
Take one step only and return, without passing TCRIT. TCRIT must be specified as under ${\mathbf{ITASK}}=4$.
Constraint: ${\mathbf{ITASK}}=1$, $2$, $3$, $4$ or $5$.
22:   ITRACE – INTEGERInput
On entry: the level of output that is printed by the integrator. ITRACE may take the value $-1$, $0$, $1$, $2$ or $3$.
${\mathbf{ITRACE}}<-1$
$-1$ is assumed and similarly if ${\mathbf{ITRACE}}>3$, then $3$ is assumed.
${\mathbf{ITRACE}}=-1$
No output is generated.
${\mathbf{ITRACE}}=0$
Only warning messages are printed on the current error message unit (see X04AAF).
${\mathbf{ITRACE}}>0$
Warning messages are printed as above, and on the current advisory message unit (see X04ABF) output is generated which details Jacobian entries, the nonlinear iteration and the time integration. The advisory messages are given in greater detail the larger the value of ITRACE.
23:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
An illegal input was detected on entry, or after an internal call to MONITR. If ${\mathbf{ITRACE}}>-1$, then the form of the error will be detailed on the current error message unit (see X04AAF).
${\mathbf{IFAIL}}=2$
The maximum number of steps specified has been taken (see the description of optional inputs in the integrator setup routines and the optional input continuation routine, D02NZF).
${\mathbf{IFAIL}}=3$
With the given values of RTOL and ATOL no further progress can be made across the integration range from the current point T. The components ${\mathbf{Y}}\left(1\right),{\mathbf{Y}}\left(2\right),\dots ,{\mathbf{Y}}\left({\mathbf{NEQ}}\right)$ contain the computed values of the solution at the current point T.
${\mathbf{IFAIL}}=4$
There were repeated error test failures on an attempted step, before completing the requested task, but the integration was successful as far as T. The problem may have a singularity, or the local error requirements may be inappropriate.
${\mathbf{IFAIL}}=5$
There were repeated convergence test failures on an attempted step, before completing the requested task, but the integration was successful as far as T. This may be caused by an inaccurate Jacobian matrix or one which is incorrectly computed.
${\mathbf{IFAIL}}=6$
Some error weight ${w}_{i}$ became zero during the integration (see the description of ITOL). Pure relative error control (${\mathbf{ATOL}}\left(i\right)=0.0$) was requested on a variable (the $i$th) which has now vanished. The integration was successful as far as T.
${\mathbf{IFAIL}}=7$
FCN set its error flag (${\mathbf{IRES}}=3$) continually despite repeated attempts by the integrator to avoid this.
${\mathbf{IFAIL}}=8$
Not used for this integrator.
${\mathbf{IFAIL}}=9$
A singular Jacobian $\frac{\partial r}{\partial y}$ has been encountered. This error exit is unlikely to be taken when solving explicit ordinary differential equations. You should check the problem formulation and Jacobian calculation.
${\mathbf{IFAIL}}=10$
An error occurred during Jacobian formulation or back-substitution (a more detailed error description may be directed to the current error message unit, see X04AAF).
${\mathbf{IFAIL}}=11$
FCN signalled the integrator to halt the integration and return (${\mathbf{IRES}}=2$). Integration was successful as far as T.
${\mathbf{IFAIL}}=12$
MONITR set ${\mathbf{IMON}}=-2$ and so forced a return but the integration was successful as far as T.
${\mathbf{IFAIL}}=13$
The requested task has been completed, but it is estimated that a small change in RTOL and ATOL is unlikely to produce any change in the computed solution. (Only applies when you are not operating in one step mode, that is when ${\mathbf{ITASK}}\ne 2$ or $5$.)
${\mathbf{IFAIL}}=14$
The values of RTOL and ATOL are so small that D02NCF is unable to start the integration.
${\mathbf{IFAIL}}=15$
The linear algebra setup routine D02NTF was not called prior to calling D02NCF.

## 7  Accuracy

The accuracy of the numerical solution may be controlled by a careful choice of the parameters RTOL and ATOL, and to a much lesser extent by the choice of norm. You are advised to use scalar error control unless the components of the solution are expected to be poorly scaled. For the type of decaying solution typical of many stiff problems, relative error control with a small absolute error threshold will be most appropriate (that is, you are advised to choose ${\mathbf{ITOL}}=1$ with ${\mathbf{ATOL}}\left(1\right)$ small but positive).

The cost of computing a solution depends critically on the size of the differential system and to a lesser extent on the degree of stiffness of the problem. For D02NCF the cost is proportional to ${\mathbf{NEQ}}×{\left({\mathbf{ML}}+{\mathbf{MU}}+1\right)}^{2}$ though for problems which are only mildly nonlinear the cost may be dominated by factors proportional to ${\mathbf{NEQ}}×\left({\mathbf{ML}}+{\mathbf{MU}}+1\right)$ except for very large problems.
In general, you are advised to choose the Backward Differentiation Formula option (setup routine D02NVF) but if efficiency is of great importance and especially if it is suspected that $\frac{\partial g}{\partial y}$ has complex eigenvalues near the imaginary axis for some part of the integration, you should try the BLEND option (setup routine D02NWF).

## 9  Example

This example solves the well-known stiff Robertson problem
 $a′ = -0.04a + 1.0E4bc b′ = 0.04a - 1.0E4bc - 3.0E7⁢b2 c′ = 3.0E7⁢b2$
over the range $\left[0,10\right]$ with initial conditions $a=1.0$ and $b=c=0.0$ using scalar relative error control and vector absolute error control $\left({\mathbf{ITOL}}=2\right)$. The solution is obtained at ${\mathbf{TOUT}}=5.0$ and ${\mathbf{TOUT}}=10.0$ by overshooting and internal ${C}^{0}$ interpolation $\left({\mathbf{ITASK}}=1\right)$. D02NBY is used for MONITR, the BLEND integrator (setup routine D02NWF) is used and the option of an analytical Jacobian is chosen.

### 9.1  Program Text

Program Text (d02ncfe.f90)

### 9.2  Program Data

Program Data (d02ncfe.d)

### 9.3  Program Results

Program Results (d02ncfe.r)