Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_inteq_volterra_weights (d05bw)

## Purpose

nag_inteq_volterra_weights (d05bw) computes the quadrature weights associated with the Adams' methods of orders three to six and the Backward Differentiation Formulae (BDF) methods of orders two to five. These rules, which are referred to as reducible quadrature rules, can then be used in the solution of Volterra integral and integro-differential equations.

## Syntax

[omega, lensw, sw, ifail] = d05bw(method, iorder, nomg, nwt)
[omega, lensw, sw, ifail] = nag_inteq_volterra_weights(method, iorder, nomg, nwt)

## Description

nag_inteq_volterra_weights (d05bw) computes the weights ${W}_{i,j}$ and ${\omega }_{i}$ for a family of quadrature rules related to the Adams' methods of orders three to six and the BDF methods of orders two to five, for approximating the integral:
 $∫0t ϕs ds ≃h ∑ j=0 p-1 Wi,j ϕj×h + h ∑ j=p i ωi-j ϕj×h , 0≤t≤T ,$ (1)
with $t=\mathit{i}×h$, for $\mathit{i}=0,1,\dots ,\mathit{n}$, for some given constant $h$.
In (1), $h$ is a uniform mesh, $\mathit{p}$ is related to the order of the method being used and ${W}_{i,j}$, ${\omega }_{i}$ are the starting and the convolution weights respectively. The mesh size $h$ is determined as $h=\frac{T}{\mathit{n}}$, where $\mathit{n}={\mathit{n}}_{w}+\mathit{p}-1$ and ${\mathit{n}}_{w}$ is the chosen number of convolution weights ${w}_{j}$, for $\mathit{j}=1,2,\dots ,{\mathit{n}}_{w}-1$. A description of how these weights can be used in the solution of a Volterra integral equation of the second kind is given in Further Comments. For a general discussion of these methods, see Wolkenfelt (1982) for more details.

## References

Lambert J D (1973) Computational Methods in Ordinary Differential Equations John Wiley
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:     $\mathrm{method}$ – string (length ≥ 1)
The type of method to be used.
${\mathbf{method}}=\text{'A'}$
${\mathbf{method}}=\text{'B'}$
For Backward Differentiation Formulae.
Constraint: ${\mathbf{method}}=\text{'A'}$ or $\text{'B'}$.
2:     $\mathrm{iorder}$int64int32nag_int scalar
The order of the method to be used. The number of starting weights, $\mathit{p}$ is determined by method and iorder.
If ${\mathbf{method}}=\text{'A'}$, $\mathit{p}={\mathbf{iorder}}-1$.
If ${\mathbf{method}}=\text{'B'}$, $\mathit{p}={\mathbf{iorder}}$.
Constraints:
• if ${\mathbf{method}}=\text{'A'}$, $3\le {\mathbf{iorder}}\le 6$;
• if ${\mathbf{method}}=\text{'B'}$, $2\le {\mathbf{iorder}}\le 5$.
3:     $\mathrm{nomg}$int64int32nag_int scalar
The number of convolution weights, ${\mathit{n}}_{w}$.
Constraint: ${\mathbf{nomg}}\ge 1$.
4:     $\mathrm{nwt}$int64int32nag_int scalar
$\mathit{p}$, the number of columns in the starting weights.
Constraints:
• if ${\mathbf{method}}=\text{'A'}$, ${\mathbf{nwt}}={\mathbf{iorder}}-1$;
• if ${\mathbf{method}}=\text{'B'}$, ${\mathbf{nwt}}={\mathbf{iorder}}$.

None.

### Output Parameters

1:     $\mathrm{omega}\left({\mathbf{nomg}}\right)$ – double array
Contains the first nomg convolution weights.
2:     $\mathrm{lensw}$int64int32nag_int scalar
The number of rows in the weights ${W}_{i,j}$.
3:     $\mathrm{sw}\left(\mathit{ldsw},{\mathbf{nwt}}\right)$ – double array
$\mathit{ldsw}=\mathit{n}$.
${\mathbf{sw}}\left(\mathit{i},\mathit{j}+1\right)$ contains the weights ${W}_{\mathit{i},\mathit{j}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{lensw}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{nwt}}-1$, where $\mathit{n}$ is as defined in Description.
4:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{method}}\ne \text{'A'}$ or $\text{'B'}$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{iorder}}<2$ or ${\mathbf{iorder}}>6$, or ${\mathbf{nomg}}<1$.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{method}}=\text{'A'}$ and ${\mathbf{iorder}}=2$, or ${\mathbf{method}}=\text{'B'}$ and ${\mathbf{iorder}}=6$.
${\mathbf{ifail}}=4$
 On entry, ${\mathbf{method}}=\text{'A'}$ and ${\mathbf{nwt}}\ne {\mathbf{iorder}}-1$, or ${\mathbf{method}}=\text{'B'}$ and ${\mathbf{nwt}}\ne {\mathbf{iorder}}$.
${\mathbf{ifail}}=5$
 On entry, ${\mathbf{method}}=\text{'A'}$ and $\mathit{ldsw}<{\mathbf{nomg}}+{\mathbf{iorder}}-2$, or ${\mathbf{method}}=\text{'B'}$ and $\mathit{ldsw}<{\mathbf{nomg}}+{\mathbf{iorder}}-1$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

Not applicable.

Reducible quadrature rules are most appropriate for solving Volterra integral equations (and integro-differential equations). In this section, we propose the following algorithm which you may find useful in solving a linear Volterra integral equation of the form
 $yt=ft+∫0tKt,sysds, 0≤t≤T,$ (2)
using nag_inteq_volterra_weights (d05bw). In (2), $K\left(t,s\right)$ and $f\left(t\right)$ are given and the solution $y\left(t\right)$ is sought on a uniform mesh of size $h$ such that $T=\mathit{n}h$. Discretization of (2) yields
 $yi=fi×h+h∑j=0 p-1Wi,jKi,h,j,hyj+h∑j=piωi-jKi,h,j,hyj,$ (3)
where ${y}_{i}\simeq y\left(i×h\right)$. We propose the following algorithm for computing ${y}_{i}$ from (3) after a call to nag_inteq_volterra_weights (d05bw):
(a) Equation (3) requires starting values, ${y}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nwt}}-1$, with ${y}_{0}=f\left(0\right)$. These starting values can be computed by solving the linear system
 $yi = fi×h + h ∑ j=0 nwt-1 swij+1 K i,h,j,h yj , i=1,2,…,nwt-1 .$
(b) Compute the inhomogeneous terms
 $σi = fi×h + h ∑ j= 0 nwt-1 swij+1 Ki,h,j,h yj , i=nwt,nwt+ 1,…,n .$
(c) Start the iteration for $i={\mathbf{nwt}},{\mathbf{nwt}}+1,\dots ,\mathit{n}$ to compute ${y}_{i}$ from:
 $1 - h × omega1 K i,h,i,h y i = σ i + h ∑ j = nwt i - 1 omega i - j + 1 K i,h,j,h y j .$
Note that for a nonlinear integral equation, the solution of a nonlinear algebraic system is required at step (a) and a single nonlinear equation at step (c).

## Example

The following example generates the first ten convolution and thirteen starting weights generated by the fourth-order BDF method.
```function d05bw_example

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

method = 'BDF';
iorder = int64(4);
nomg = int64(10);
nwt = int64(4);
[omega, lensw, sw, ifail] = d05bw( ...
method, iorder, nomg, nwt);

fprintf('\nThe convolution weights\n\n');
n = [0:double(nomg)-1]';
fprintf('%3d    %10.4f\n',[n omega]');

fprintf('\nThe weights W\n\n');
n = [1:double(lensw)]';
fprintf('%3d    %10.4f%10.4f%10.4f%10.4f\n',[n sw]');

```
```d05bw example results

The convolution weights

0        0.4800
1        0.9216
2        1.0783
3        1.0504
4        0.9962
5        0.9797
6        0.9894
7        1.0003
8        1.0034
9        1.0017

The weights W

1        0.3750    0.7917   -0.2083    0.0417
2        0.3333    1.3333    0.3333    0.0000
3        0.3750    1.1250    1.1250    0.3750
4        0.4800    0.7467    1.5467    0.7467
5        0.5499    0.5719    1.5879    0.8886
6        0.5647    0.5829    1.5016    0.8709
7        0.5545    0.6385    1.4514    0.8254
8        0.5458    0.6629    1.4550    0.8098
9        0.5449    0.6578    1.4741    0.8170
10        0.5474    0.6471    1.4837    0.8262
11        0.5491    0.6428    1.4831    0.8292
12        0.5492    0.6438    1.4798    0.8279
13        0.5488    0.6457    1.4783    0.8263
```