# NAG FL Interfaced05bwf (volterra_​weights)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d05bwf 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.

## 2Specification

Fortran Interface
 Subroutine d05bwf ( nomg, sw, ldsw, nwt,
 Integer, Intent (In) :: iorder, nomg, ldsw, nwt Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: lensw Real (Kind=nag_wp), Intent (Inout) :: sw(ldsw,nwt) Real (Kind=nag_wp), Intent (Out) :: omega(nomg) Character (1), Intent (In) :: method
#include <nag.h>
 void d05bwf_ (const char *method, const Integer *iorder, double omega[], const Integer *nomg, Integer *lensw, double sw[], const Integer *ldsw, const Integer *nwt, Integer *ifail, const Charlen length_method)
The routine may be called by the names d05bwf or nagf_inteq_volterra_weights.

## 3Description

d05bwf 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 Section 9. For a general discussion of these methods, see Wolkenfelt (1982) for more details.

## 4References

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

## 5Arguments

1: $\mathbf{method}$Character(1) Input
On entry: the type of method to be used.
${\mathbf{method}}=\text{'A'}$
For Adams' type formulae.
${\mathbf{method}}=\text{'B'}$
For Backward Differentiation Formulae.
Constraint: ${\mathbf{method}}=\text{'A'}$ or $\text{'B'}$.
2: $\mathbf{iorder}$Integer Input
On entry: 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: $\mathbf{omega}\left({\mathbf{nomg}}\right)$Real (Kind=nag_wp) array Output
On exit: contains the first nomg convolution weights.
4: $\mathbf{nomg}$Integer Input
On entry: the number of convolution weights, ${\mathit{n}}_{w}$.
Constraint: ${\mathbf{nomg}}\ge 1$.
5: $\mathbf{lensw}$Integer Output
On exit: the number of rows in the weights ${W}_{i,j}$.
6: $\mathbf{sw}\left({\mathbf{ldsw}},{\mathbf{nwt}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\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 Section 3.
7: $\mathbf{ldsw}$Integer Input
On entry: the first dimension of the array sw as declared in the (sub)program from which d05bwf is called.
Constraints:
• if ${\mathbf{method}}=\text{'A'}$, ${\mathbf{ldsw}}\ge {\mathbf{nomg}}+{\mathbf{iorder}}-2$;
• if ${\mathbf{method}}=\text{'B'}$, ${\mathbf{ldsw}}\ge {\mathbf{nomg}}+{\mathbf{iorder}}-1$.
8: $\mathbf{nwt}$Integer Input
On entry: $\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}}$.
9: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{method}}=\text{'A'}$ or $\text{'B'}$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{iorder}}=⟨\mathit{\text{value}}⟩$.
Constraint: $2\le {\mathbf{iorder}}\le 6$.
On entry, ${\mathbf{nomg}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nomg}}\ge 1$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{method}}=\text{'A'}$ and ${\mathbf{iorder}}=2$.
Constraint: if ${\mathbf{method}}=\text{'A'}$, $3\le {\mathbf{iorder}}\le 6$.
On entry, ${\mathbf{method}}=\text{'B'}$ and ${\mathbf{iorder}}=6$.
Constraint: if ${\mathbf{method}}=\text{'B'}$, $2\le {\mathbf{iorder}}\le 5$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{method}}=\text{'A'}$, ${\mathbf{iorder}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nwt}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{method}}=\text{'A'}$, ${\mathbf{nwt}}={\mathbf{iorder}}-1$.
On entry, ${\mathbf{method}}=\text{'B'}$, ${\mathbf{iorder}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nwt}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{method}}=\text{'B'}$, ${\mathbf{nwt}}={\mathbf{iorder}}$.
${\mathbf{ifail}}=5$
On entry, ${\mathbf{method}}=\text{'A'}$, ${\mathbf{iorder}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nomg}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{ldsw}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{method}}=\text{'A'}$, ${\mathbf{ldsw}}\ge {\mathbf{nomg}}+{\mathbf{iorder}}-2$.
On entry, ${\mathbf{method}}=\text{'B'}$, ${\mathbf{iorder}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nomg}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{ldsw}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{method}}=\text{'B'}$, ${\mathbf{ldsw}}\ge {\mathbf{nomg}}+{\mathbf{iorder}}-1$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
d05bwf is not threaded in any implementation.

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
 $y(t)=f(t)+∫0tK(t,s)y(s)ds, 0≤t≤T,$ (2)
using d05bwf. 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=f(i×h)+h∑j=0 p-1Wi,jK(i,h,j,h)yj+h∑j=piωi-jK(i,h,j,h)yj,$ (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 d05bwf:
1. (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 = f(i×h) + h ∑ j=0 nwt-1 sw(i,j+1) K (i,h,j,h) yj , i=1,2,…,nwt-1 .$
2. (b)Compute the inhomogeneous terms
 $σi = f(i×h) + h ∑ j= 0 nwt-1 sw(i,j+1) K(i,h,j,h) yj , i=nwt,nwt+ 1,…,n .$
3. (c)Start the iteration for $i={\mathbf{nwt}},{\mathbf{nwt}}+1,\dots ,\mathit{n}$ to compute ${y}_{i}$ from:
 $(1-h×omega(1)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).

## 10Example

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

### 10.1Program Text

Program Text (d05bwfe.f90)

None.

### 10.3Program Results

Program Results (d05bwfe.r)