hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_inteq_volterra2 (d05ba)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_inteq_volterra2 (d05ba) computes the solution of a nonlinear convolution Volterra integral equation of the second kind using a reducible linear multi-step method.

Syntax

[yn, errest, work, ifail] = d05ba(ck, cg, cf, method, iorder, alim, tlim, nmesh, tol, thresh, lwk)
[yn, errest, work, ifail] = nag_inteq_volterra2(ck, cg, cf, method, iorder, alim, tlim, nmesh, tol, thresh, lwk)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: work was made an output parameter

Description

nag_inteq_volterra2 (d05ba) computes the numerical solution of the nonlinear convolution Volterra integral equation of the second kind
yt=ft+atkt-sgs,ysds,  atT. (1)
It is assumed that the functions involved in (1) are sufficiently smooth. The function uses a reducible linear multi-step formula selected by you to generate a family of quadrature rules. The reducible formulae available in nag_inteq_volterra2 (d05ba) 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 step-by-step fashion on a mesh of equispaced points. The initial step size which is given by T-a/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 user-specified 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, kt, on the negative real line.

References

Lubich Ch (1983) On the stability of linear multi-step 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 integro-differential equations IMA J. Numer. Anal. 2 131–152

Parameters

Compulsory Input Parameters

1:     ck – function handle or string containing name of m-file
ck must evaluate the kernel kt of the integral equation (1).
[result] = ck(t)

Input Parameters

1:     t – double scalar
t, the value of the independent variable.

Output Parameters

1:     result – double scalar
The value of the kernel kt evaluated at t.
2:     cg – function handle or string containing name of m-file
cg must evaluate the function gs,ys in (1).
[result] = cg(s, y)

Input Parameters

1:     s – double scalar
s, the value of the independent variable.
2:     y – double scalar
The value of the solution y at the point s.

Output Parameters

1:     result – double scalar
The value of gs,ys evaluated at s and y.
3:     cf – function handle or string containing name of m-file
cf must evaluate the function ft in (1).
[result] = cf(t)

Input Parameters

1:     t – double scalar
t, the value of the independent variable.

Output Parameters

1:     result – double scalar
The value of ft evaluated at t.
4:     method – string (length ≥ 1)
The type of method which you wish to employ.
method='A'
For Adams' type formulae.
method='B'
For backward differentiation formulae.
Constraint: method='A' or 'B'.
5:     iorder int64int32nag_int scalar
The order of the method to be used.
Constraints:
  • if method='A', 3iorder6;
  • if method='B', 2iorder5.
6:     alim – double scalar
a, the lower limit of the integration interval.
Constraint: alim0.0.
7:     tlim – double scalar
The final point of the integration interval, T.
Constraint: tlim>alim.
8:     nmesh int64int32nag_int scalar
The number of equidistant points at which the solution is sought.
Constraints:
  • if method='A', nmeshiorder-1;
  • if method='B', nmeshiorder.
9:     tol – double scalar
The relative accuracy required in the computed values of the solution.
Constraint: εtol1.0, where ε is the machine precision.
10:   thresh – double scalar
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
Y1-Y2 maxY1,Y2,thresh tol,  
where Y1 is the computed solution on the coarser mesh and Y2 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 thresh=0.0 then pure relative error is measured and, if the computed solution is small and thresh=1.0, absolute error is measured.
11:   lwk int64int32nag_int scalar
The dimension of the array work.
Constraint: lwk10×nmesh+6.
Note: the above value of lwk is sufficient for nag_inteq_volterra2 (d05ba) 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.

Optional Input Parameters

None.

Output Parameters

1:     ynnmesh – double array
yni contains the most recent approximation of the true solution yt at the specified point t=alim+i×H, for i=1,2,,nmesh, where H=tlim-alim/nmesh.
2:     errestnmesh – double array
erresti contains the most recent approximation of the relative error in the computed solution at the point t=alim+i×H, for i=1,2,,nmesh, where H=tlim-alim/nmesh.
3:     worklwk – double array
If ifail=5 or 6, work1 contains the size of lwk required for the algorithm to proceed further.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,method'A' or 'B',
oriorder<2 or iorder>6,
ormethod='A' and iorder=2,
ormethod='B' and iorder=6,
oralim<0.0,
ortlimalim,
ortol<ε or tol>1.0, where ε is the machine precision.
   ifail=2
On entry,nmeshiorder-2, when method='A',
ornmeshiorder-1, when method='B'.
   ifail=3
On entry,lwk<10×nmesh+6.
   ifail=4
The solution of the nonlinear equation (2) (see Further Comments for further details) could not be computed by nag_roots_contfn_interval_rcomm (c05av) and nag_roots_contfn_brent_rcomm (c05az).
   ifail=5
The size of the workspace lwk is too small for the required accuracy. The computation has failed in its initial phase (see Further Comments for further details).
   ifail=6
The size of the workspace lwk is too small for the required accuracy on the interval alim,tlim (see Further Comments for further details).
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

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 ifail=5 or 6.
In general, the higher the order of the method, the faster the required accuracy is achieved with less workspace. For non-stiff problems (see Further Comments) you are recommended to use the Adams' method (method='A') of order greater than 4 (iorder>4).

Further Comments

When solving (1), the solution of a nonlinear equation of the form
Yn-αgtn,Yn-Ψn=0, (2)
is required, where Ψn and α are constants. nag_inteq_volterra2 (d05ba) calls nag_roots_contfn_interval_rcomm (c05av) to find an interval for the zero of this equation followed by nag_roots_contfn_brent_rcomm (c05az) 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, nag_inteq_volterra2 (d05ba) will exit with ifail=5.
In the case ifail=4 or 5, you may be dealing with a ‘stiff’ equation; an equation where the Lipschitz constant L of the function gt,y in (1) with respect to its second argument is large, viz,
gt,u-gt,vLu-v. (3)
In this case, if a BDF method (method='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 (method='A') has been selected, you are recommended to switch to a BDF method instead.
In the case ifail=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 work1.

Example

Consider the following integral equation
yt=e-t+0te-t-sys+e-ysds,  0t20 (4)
with the solution yt=lnt+e. In this example, the Adams' method of order 6 is used to solve this equation with tol=1.e−4.
function d05ba_example


fprintf('d05ba example results\n\n');

ck = @(t) exp(-t);
cg = @(s, y) y + exp(-y);
cf = @(t) exp(-t);
method = 'A';
iorder = int64(6);
alim = 0;
tlim = 20;
nmesh = int64(6);
tol = 0.001;
thresh = x02aj;
lwk = int64(1000);
[yn, errest, work, ifail] = ...
  d05ba( ...
	 ck, cg, cf, method, iorder, alim, tlim, nmesh, tol, thresh, lwk);

fprintf('Workspace requested = %4d\n', lwk);
fprintf('Tolerance           = %8.2e\n\n', tol);
fprintf('  t        approx. sol.  true sol.  est. error    actual error\n');
dt = (tlim-alim)/(double(nmesh));
t = [alim+dt:dt:tlim];
sol = log(t+exp(1))';
err = abs(yn-sol)./sol;
fprintf('%6.2f%14.5f%12.5f%15.5e%15.5e\n', [t' yn sol errest, err]');


d05ba example results

Workspace requested = 1000
Tolerance           = 1.00e-03

  t        approx. sol.  true sol.  est. error    actual error
  3.33       1.80037     1.80033    8.03776e-05    2.38466e-05
  6.67       2.23916     2.23911    1.77740e-04    2.34772e-05
 10.00       2.54310     2.54304    2.45949e-04    2.24564e-05
 13.33       2.77587     2.77581    3.05737e-04    2.17430e-05
 16.67       2.96456     2.96450    3.61698e-04    2.13821e-05
 20.00       3.12324     3.12317    4.17127e-04    2.13102e-05

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015