NAG Library Routine Document
D05BAF
1 Purpose
D05BAF computes the solution of a nonlinear convolution Volterra integral equation of the second kind using a reducible linear multistep method.
2 Specification
SUBROUTINE D05BAF ( 
CK, CG, CF, METHOD, IORDER, ALIM, TLIM, YN, ERREST, NMESH, TOL, THRESH, WORK, LWK, IFAIL) 
INTEGER 
IORDER, NMESH, LWK, IFAIL 
REAL (KIND=nag_wp) 
CK, CG, CF, ALIM, TLIM, YN(NMESH), ERREST(NMESH), TOL, THRESH, WORK(LWK) 
CHARACTER(1) 
METHOD 
EXTERNAL 
CK, CG, CF 

3 Description
D05BAF computes the numerical solution of the nonlinear convolution Volterra integral equation of the second kind
It is assumed that the functions involved in
(1) are sufficiently smooth. The routine uses a reducible linear multistep formula selected by you to generate a family of quadrature rules. The reducible formulae available in D05BAF are the Adams–Moulton formulae of orders
$3$ to
$6$, and the backward differentiation formulae (BDF) of orders
$2$ to
$5$. For more information about the behaviour and the construction of these rules we refer to
Lubich (1983) and
Wolkenfelt (1982).
The algorithm is based on computing the solution in a stepbystep fashion on a mesh of equispaced points. The initial step size which is given by $\left(Ta\right)/N$, $N$ being the number of points at which the solution is sought, is halved and another approximation to the solution is computed. This extrapolation procedure is repeated until successive approximations satisfy a userspecified error requirement.
The above methods require some starting values. For the Adams' formula of order greater than
$3$ and the BDF of order greater than
$2$ we employ an explicit Dormand–Prince–Shampine Runge–Kutta method (see
Shampine (1986)). The above scheme avoids the calculation of the kernel,
$k\left(t\right)$, on the negative real line.
4 References
Lubich Ch (1983) On the stability of linear multistep methods for Volterra convolution equations IMA J. Numer. Anal. 3 439–465
Shampine L F (1986) Some practical Runge–Kutta formulas Math. Comput. 46(173) 135–150
Wolkenfelt P H M (1982) The construction of reducible quadrature rules for Volterra integral and integrodifferential equations IMA J. Numer. Anal. 2 131–152
5 Parameters
 1: $\mathrm{CK}$ – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure

CK must evaluate the kernel
$k\left(t\right)$ of the integral equation
(1).
The specification of
CK is:
 1: $\mathrm{T}$ – REAL (KIND=nag_wp)Input

On entry: $t$, the value of the independent variable.
CK must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05BAF is called. Parameters denoted as
Input must
not be changed by this procedure.
 2: $\mathrm{CG}$ – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure

CG must evaluate the function
$g\left(s,y\left(s\right)\right)$ in
(1).
The specification of
CG is:
 1: $\mathrm{S}$ – REAL (KIND=nag_wp)Input

On entry: $s$, the value of the independent variable.
 2: $\mathrm{Y}$ – REAL (KIND=nag_wp)Input

On entry: the value of the solution
$y$ at the point
S.
CG must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05BAF is called. Parameters denoted as
Input must
not be changed by this procedure.
 3: $\mathrm{CF}$ – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure

CF must evaluate the function
$f\left(t\right)$ in
(1).
The specification of
CF is:
 1: $\mathrm{T}$ – REAL (KIND=nag_wp)Input

On entry: $t$, the value of the independent variable.
CF must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05BAF is called. Parameters denoted as
Input must
not be changed by this procedure.
 4: $\mathrm{METHOD}$ – CHARACTER(1)Input

On entry: the type of method which you wish to employ.
 ${\mathbf{METHOD}}=\text{'A'}$
 For Adams' type formulae.
 ${\mathbf{METHOD}}=\text{'B'}$
 For backward differentiation formulae.
Constraint:
${\mathbf{METHOD}}=\text{'A'}$ or $\text{'B'}$.
 5: $\mathrm{IORDER}$ – INTEGERInput

On entry: the order of the method to be used.
Constraints:
 if ${\mathbf{METHOD}}=\text{'A'}$, $3\le {\mathbf{IORDER}}\le 6$;
 if ${\mathbf{METHOD}}=\text{'B'}$, $2\le {\mathbf{IORDER}}\le 5$.
 6: $\mathrm{ALIM}$ – REAL (KIND=nag_wp)Input

On entry: $a$, the lower limit of the integration interval.
Constraint:
${\mathbf{ALIM}}\ge 0.0$.
 7: $\mathrm{TLIM}$ – REAL (KIND=nag_wp)Input

On entry: the final point of the integration interval, $T$.
Constraint:
${\mathbf{TLIM}}>{\mathbf{ALIM}}$.
 8: $\mathrm{YN}\left({\mathbf{NMESH}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: ${\mathbf{YN}}\left(\mathit{i}\right)$ contains the most recent approximation of the true solution $y\left(t\right)$ at the specified point $t={\mathbf{ALIM}}+\mathit{i}\times H$, for $\mathit{i}=1,2,\dots ,{\mathbf{NMESH}}$, where $H=\left({\mathbf{TLIM}}{\mathbf{ALIM}}\right)/{\mathbf{NMESH}}$.
 9: $\mathrm{ERREST}\left({\mathbf{NMESH}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: ${\mathbf{ERREST}}\left(\mathit{i}\right)$ contains the most recent approximation of the relative error in the computed solution at the point $t={\mathbf{ALIM}}+\mathit{i}\times H$, for $\mathit{i}=1,2,\dots ,{\mathbf{NMESH}}$, where $H=\left({\mathbf{TLIM}}{\mathbf{ALIM}}\right)/{\mathbf{NMESH}}$.
 10: $\mathrm{NMESH}$ – INTEGERInput

On entry: the number of equidistant points at which the solution is sought.
Constraints:
 if ${\mathbf{METHOD}}=\text{'A'}$, ${\mathbf{NMESH}}\ge {\mathbf{IORDER}}1$;
 if ${\mathbf{METHOD}}=\text{'B'}$, ${\mathbf{NMESH}}\ge {\mathbf{IORDER}}$.
 11: $\mathrm{TOL}$ – REAL (KIND=nag_wp)Input

On entry: the relative accuracy required in the computed values of the solution.
Constraint:
$\sqrt{\epsilon}\le {\mathbf{TOL}}\le 1.0$, where $\epsilon $ is the machine precision.
 12: $\mathrm{THRESH}$ – REAL (KIND=nag_wp)Input

On entry: the threshold value for use in the evaluation of the estimated relative errors. For two successive meshes the following condition must hold at each point of the coarser mesh
where
${Y}_{1}$ is the computed solution on the coarser mesh and
${Y}_{2}$ is the computed solution at the corresponding point in the finer mesh. If this condition is not satisfied then the step size is halved and the solution is recomputed.
Note: THRESH can be used to effect a relative, absolute or mixed error test. If
${\mathbf{THRESH}}=0.0$ then pure relative error is measured and, if the computed solution is small and
${\mathbf{THRESH}}=1.0$, absolute error is measured.
 13: $\mathrm{WORK}\left({\mathbf{LWK}}\right)$ – REAL (KIND=nag_wp) arrayOutput
 14: $\mathrm{LWK}$ – INTEGERInput

On entry: the dimension of the array
WORK as declared in the (sub)program from which D05BAF is called.
Constraint:
${\mathbf{LWK}}\ge 10\times {\mathbf{NMESH}}+6$.
Note: the above value of
LWK is sufficient for D05BAF to perform only one extrapolation on the initial mesh as defined by
NMESH. In general much more workspace is required and in the case when a large step size is supplied (i.e.,
NMESH is small), you must provide a considerably larger workspace.
On exit: if
${\mathbf{IFAIL}}={\mathbf{5}}$ or
${\mathbf{6}}$,
${\mathbf{WORK}}\left(1\right)$ contains the size of
LWK required for the algorithm to proceed further.
 15: $\mathrm{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, if you are not familiar with this parameter, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{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$

On entry,  ${\mathbf{METHOD}}\ne \text{'A'}$ or $\text{'B'}$, 
or  ${\mathbf{IORDER}}<2$ or ${\mathbf{IORDER}}>6$, 
or  ${\mathbf{METHOD}}=\text{'A'}$ and ${\mathbf{IORDER}}=2$, 
or  ${\mathbf{METHOD}}=\text{'B'}$ and ${\mathbf{IORDER}}=6$, 
or  ${\mathbf{ALIM}}<0.0$, 
or  ${\mathbf{TLIM}}\le {\mathbf{ALIM}}$, 
or  ${\mathbf{TOL}}<\sqrt{\epsilon}$ or ${\mathbf{TOL}}>1.0$, where $\epsilon $ is the machine precision. 
 ${\mathbf{IFAIL}}=2$

On entry,  ${\mathbf{NMESH}}\le {\mathbf{IORDER}}2$, when ${\mathbf{METHOD}}=\text{'A'}$, 
or  ${\mathbf{NMESH}}\le {\mathbf{IORDER}}1$, when ${\mathbf{METHOD}}=\text{'B'}$. 
 ${\mathbf{IFAIL}}=3$

On entry,  ${\mathbf{LWK}}<10\times {\mathbf{NMESH}}+6$. 
 ${\mathbf{IFAIL}}=4$

The solution of the nonlinear equation
(2) (see
Section 9 for further details) could not be computed by
C05AVF and
C05AZF.
 ${\mathbf{IFAIL}}=5$

The size of the workspace
LWK is too small for the required accuracy. The computation has failed in its initial phase (see
Section 9 for further details).
 ${\mathbf{IFAIL}}=6$

The size of the workspace
LWK is too small for the required accuracy on the interval
$\left[{\mathbf{ALIM}},{\mathbf{TLIM}}\right]$ (see
Section 9 for further details).
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
 ${\mathbf{IFAIL}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
The accuracy depends on
TOL, the theoretical behaviour of the solution of the integral equation, the interval of integration and on the method being used. It can be controlled by varying
TOL and
THRESH; you are recommended to choose a smaller value for
TOL, the larger the value of
IORDER.
You are warned not to supply a very small
TOL, because the required accuracy may never be achieved. This will usually force an error exit with
${\mathbf{IFAIL}}={\mathbf{5}}$ or
${\mathbf{6}}$.
In general, the higher the order of the method, the faster the required accuracy is achieved with less workspace. For nonstiff problems (see
Section 9) you are recommended to use the Adams' method (
${\mathbf{METHOD}}=\text{'A'}$) of order greater than
$4$ (
${\mathbf{IORDER}}>4$).
8 Parallelism and Performance
Not applicable.
When solving
(1), the solution of a nonlinear equation of the form
is required, where
${\Psi}_{n}$ and
$\alpha $ are constants. D05BAF calls
C05AVF to find an interval for the zero of this equation followed by
C05AZF to find its zero.
There is an initial phase of the algorithm where the solution is computed only for the first few points of the mesh. The exact number of these points depends on
IORDER and
METHOD. The step size is halved until the accuracy requirements are satisfied on these points and only then the solution on the whole mesh is computed. During this initial phase, if
LWK is too small, D05BAF will exit with
${\mathbf{IFAIL}}={\mathbf{5}}$.
In the case
${\mathbf{IFAIL}}={\mathbf{4}}$ or
${\mathbf{5}}$, you may be dealing with a ‘stiff’ equation; an equation where the Lipschitz constant
$L$ of the function
$g\left(t,y\right)$ in
(1) with respect to its second argument is large, viz,
In this case, if a BDF method (
${\mathbf{METHOD}}=\text{'B'}$) has been used, you are recommended to choose a smaller step size by increasing the value of
NMESH, or provide a larger workspace. But, if an Adams' method (
${\mathbf{METHOD}}=\text{'A'}$) has been selected, you are recommended to switch to a BDF method instead.
In the case
${\mathbf{IFAIL}}={\mathbf{6}}$,
the specified accuracy has not been attained but
YN and
ERREST contain the most recent approximation to the computed solution and the corresponding error estimate. In this case, the error message informs you of the number of extrapolations performed and the size of
LWK required for the algorithm to proceed further. The latter quantity will also be available in
${\mathbf{WORK}}\left(1\right)$.
10 Example
Consider the following integral equation
with the solution
$y\left(t\right)=\mathrm{ln}\left(t+e\right)$. In this example, the Adams' method of order
$6$ is used to solve this equation with
${\mathbf{TOL}}=\text{1.E\u22124}$.
10.1 Program Text
Program Text (d05bafe.f90)
10.2 Program Data
None.
10.3 Program Results
Program Results (d05bafe.r)