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_abel2_weak (d05bd)

## Purpose

nag_inteq_abel2_weak (d05bd) computes the solution of a weakly singular nonlinear convolution Volterra–Abel integral equation of the second kind using a fractional Backward Differentiation Formulae (BDF) method.

## Syntax

[yn, work, ifail] = d05bd(ck, cf, cg, initwt, tlim, nmesh, work, 'iorder', iorder, 'tolnl', tolnl)
[yn, work, ifail] = nag_inteq_abel2_weak(ck, cf, cg, initwt, tlim, nmesh, work, 'iorder', iorder, 'tolnl', tolnl)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: lwk has been removed from the interface
.

## Description

nag_inteq_abel2_weak (d05bd) computes the numerical solution of the weakly singular convolution Volterra–Abel integral equation of the second kind
 t y(t) = f(t) + 1/(sqrt(π)) ∫ (k(t − s))/(sqrt(t − s))g(s,y(s))ds,  0 ≤ t ≤ T. 0
$y(t) = f(t) + 1π ∫0t k(t-s) t-s g (s,y(s)) ds , 0≤t≤T .$
(1)
Note the constant 1/(sqrt(π))$\frac{1}{\sqrt{\pi }}$ in (1). It is assumed that the functions involved in (1) are sufficiently smooth.
The function uses a fractional BDF linear multi-step method to generate a family of quadrature rules (see nag_inteq_abel_weak_weights (d05by)). The BDF methods available in nag_inteq_abel2_weak (d05bd) are of orders 4$4$, 5$5$ and 6$6$ ( = p$\text{}=p$ say). For a description of the theoretical and practical background to these methods we refer to Lubich (1985) and to Baker and Derakhshan (1987) and Hairer et al. (1988) respectively.
The algorithm is based on computing the solution y(t)$y\left(t\right)$ in a step-by-step fashion on a mesh of equispaced points. The size of the mesh is given by T / (N1)$T/\left(N-1\right)$, N$N$ being the number of points at which the solution is sought. These methods require 2p1$2p-1$ (including y(0)$y\left(0\right)$) starting values which are evaluated internally. The computation of the lag term arising from the discretization of (1) is performed by fast Fourier transform (FFT) techniques when N > 32 + 2p1$N>32+2p-1$, and directly otherwise. The function does not provide an error estimate and you are advised to check the behaviour of the solution with a different value of N$N$. An option is provided which avoids the re-evaluation of the fractional weights when nag_inteq_abel2_weak (d05bd) is to be called several times (with the same value of N$N$) within the same program unit with different functions.

## References

Baker C T H and Derakhshan M S (1987) FFT techniques in the numerical solution of convolution equations J. Comput. Appl. Math. 20 5–24
Hairer E, Lubich Ch and Schlichte M (1988) Fast numerical solution of weakly singular Volterra integral equations J. Comput. Appl. Math. 23 87–98
Lubich Ch (1985) Fractional linear multistep methods for Abel–Volterra integral equations of the second kind Math. Comput. 45 463–469

## Parameters

### Compulsory Input Parameters

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

Input Parameters

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

Output Parameters

1:     result – double scalar
The result of the function.
2:     cf – function handle or string containing name of m-file
cf must evaluate the function f(t)$f\left(t\right)$ in (1).
[result] = cf(t)

Input Parameters

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

Output Parameters

1:     result – double scalar
The result of the function.
3:     cg – function handle or string containing name of m-file
cg must evaluate the function g(s,y(s))$g\left(s,y\left(s\right)\right)$ in (1).
[result] = cg(s, y)

Input Parameters

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

Output Parameters

1:     result – double scalar
The result of the function.
4:     initwt – string (length ≥ 1)
If the fractional weights required by the method need to be calculated by the function then set initwt = 'I'${\mathbf{initwt}}=\text{'I'}$ (Initial call).
If initwt = 'S'${\mathbf{initwt}}=\text{'S'}$ (Subsequent call), the function assumes the fractional weights have been computed on a previous call and are stored in work.
Constraint: initwt = 'I'${\mathbf{initwt}}=\text{'I'}$ or 'S'$\text{'S'}$.
Note: when nag_inteq_abel2_weak (d05bd) is re-entered with the value of initwt = 'S'${\mathbf{initwt}}=\text{'S'}$, the values of nmesh, iorder and the contents of work must not be changed.
5:     tlim – double scalar
The final point of the integration interval, T$T$.
Constraint: tlim > 10 × machine precision.
6:     nmesh – int64int32nag_int scalar
N$N$, the number of equispaced points at which the solution is sought.
Constraint: nmesh = 2m + 2 × iorder1${\mathbf{nmesh}}={2}^{m}+2×{\mathbf{iorder}}-1$, where m1$m\ge 1$.
7:     work(lwk) – double array
lwk, the dimension of the array, must satisfy the constraint lwk(2 × iorder + 6) × nmesh + 8 × 16 × iorder + 1$\mathit{lwk}\ge \left(2×{\mathbf{iorder}}+6\right)×{\mathbf{nmesh}}+8×{{\mathbf{iorder}}}^{2}-16×{\mathbf{iorder}}+1$.
If initwt = 'S'${\mathbf{initwt}}=\text{'S'}$, work must contain fractional weights computed by a previous call of nag_inteq_abel2_weak (d05bd) (see description of initwt).

### Optional Input Parameters

1:     iorder – int64int32nag_int scalar
p$p$, the order of the BDF method to be used.
Default: 4$4$
Constraint: 4iorder6$4\le {\mathbf{iorder}}\le 6$.
2:     tolnl – double scalar
The accuracy required for the computation of the starting value and the solution of the nonlinear equation at each step of the computation (see Section [Further Comments]).
Default: sqrt(machine precision)$\sqrt{\mathbit{machine precision}}$
Constraint: tolnl > 10 × machine precision.

lwk nct

### Output Parameters

1:     yn(nmesh) – double array
yn(i)${\mathbf{yn}}\left(\mathit{i}\right)$ contains the approximate value of the true solution y(t)$y\left(t\right)$ at the point t = (i1) × h$t=\left(\mathit{i}-1\right)×h$, for i = 1,2,,nmesh$\mathit{i}=1,2,\dots ,{\mathbf{nmesh}}$, where h = tlim / (nmesh1)$h={\mathbf{tlim}}/\left({\mathbf{nmesh}}-1\right)$.
2:     work(lwk) – double array
lwk(2 × iorder + 6) × nmesh + 8 × 16 × iorder + 1$\mathit{lwk}\ge \left(2×{\mathbf{iorder}}+6\right)×{\mathbf{nmesh}}+8×{{\mathbf{iorder}}}^{2}-16×{\mathbf{iorder}}+1$.
Contains fractional weights which may be used by a subsequent call of nag_inteq_abel2_weak (d05bd).
3:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail = 1${\mathbf{ifail}}=1$
 On entry, iorder < 4${\mathbf{iorder}}<4$ or iorder > 6${\mathbf{iorder}}>6$, or tlim ≤ 10 × machine precision, or initwt ≠ 'I'${\mathbf{initwt}}\ne \text{'I'}$ or 'S'$\text{'S'}$, or initwt = 'S'${\mathbf{initwt}}=\text{'S'}$ on the first call to nag_inteq_abel2_weak (d05bd), or tolnl ≤ 10 × machine precision, or nmesh ≠ 2m + 2 × iorder − 1,m ≥ 1${\mathbf{nmesh}}\ne {2}^{m}+2×{\mathbf{iorder}}-1,m\ge 1$, or lwk < (2 × iorder + 6) × nmesh + 8 × − 16 × iorder + 1$\mathit{lwk}<\left(2×{\mathbf{iorder}}+6\right)×{\mathbf{nmesh}}+8×{{\mathbf{iorder}}}^{2}-16×{\mathbf{iorder}}+1$.
ifail = 2${\mathbf{ifail}}=2$
The function cannot compute the 2p1$2p-1$ starting values due to an error solving the system of nonlinear equations. Relaxing the value of tolnl and/or increasing the value of nmesh may overcome this problem (see Section [Further Comments] for further details).
ifail = 3${\mathbf{ifail}}=3$
The function cannot compute the solution at a specific step due to an error in the solution of the nonlinear equation (2). Relaxing the value of tolnl and/or increasing the value of nmesh may overcome this problem (see Section [Further Comments] for further details).

## Accuracy

The accuracy depends on nmesh and tolnl, the theoretical behaviour of the solution of the integral equation and the interval of integration. The value of tolnl controls the accuracy required for computing the starting values and the solution of (2) at each step of computation. This value can affect the accuracy of the solution. However, for most problems, the value of sqrt(ε)$\sqrt{\epsilon }$, where ε$\epsilon$ is the machine precision, should be sufficient.

In solving (1), initially, nag_inteq_abel2_weak (d05bd) computes the solution of a system of nonlinear equations for obtaining the 2p1$2p-1$ starting values. nag_roots_sys_func_rcomm (c05qd) is used for this purpose. When a failure with ${\mathbf{ifail}}={\mathbf{2}}$ occurs (which corresponds to an error exit from nag_roots_sys_func_rcomm (c05qd)), you are advised to either relax the value of tolnl or choose a smaller step size by increasing the value of nmesh. Once the starting values are computed successfully, the solution of a nonlinear equation of the form
 Yn − αg(tn,Yn) − Ψn = 0, $Yn-αg(tn,Yn)-Ψn=0,$ (2)
is required at each step of computation, where Ψn${\Psi }_{n}$ and α$\alpha$ are constants. nag_inteq_abel2_weak (d05bd) calls nag_roots_contfn_cntin_rcomm (c05ax) to find the root of this equation.
If a failure with ${\mathbf{ifail}}={\mathbf{3}}$ occurs (which corresponds to an error exit from nag_roots_contfn_cntin_rcomm (c05ax)), you are advised to relax the value of the tolnl or choose a smaller step size by increasing the value of nmesh.
If a failure with ${\mathbf{ifail}}={\mathbf{2}}$ or 3${\mathbf{3}}$ persists even after adjustments to tolnl and/or nmesh then you should consider whether there is a more fundamental difficulty. For example, the problem is ill-posed or the functions in (1) are not sufficiently smooth.

## Example

```function nag_inteq_abel2_weak_example
ck = @(t) -sqrt(pi);
cf = @(t) sqrt(t) + (3/8)*t*t*pi;
cg = @(s, y) y^3;
initwt = 'Initial';
tlim = 7;
nmesh = int64(71);
work = zeros(1059, 1);
[yn, workOut, ifail] = nag_inteq_abel2_weak(ck, cf, cg, initwt, tlim, nmesh, work);
yn, ifail
```
```

yn =

0
0.3162
0.4472
0.5477
0.6325
0.7071
0.7746
0.8367
0.8944
0.9487
1.0000
1.0488
1.0954
1.1402
1.1832
1.2247
1.2649
1.3038
1.3416
1.3784
1.4142
1.4491
1.4832
1.5166
1.5492
1.5811
1.6125
1.6432
1.6733
1.7029
1.7321
1.7607
1.7889
1.8166
1.8439
1.8708
1.8974
1.9235
1.9494
1.9748
2.0000
2.0248
2.0494
2.0736
2.0976
2.1213
2.1448
2.1679
2.1909
2.2136
2.2361
2.2583
2.2804
2.3022
2.3238
2.3452
2.3664
2.3875
2.4083
2.4290
2.4495
2.4698
2.4900
2.5100
2.5298
2.5495
2.5690
2.5884
2.6077
2.6268
2.6458

ifail =

0

```
```function d05bd_example
ck = @(t) -sqrt(pi);
cf = @(t) sqrt(t) + (3/8)*t*t*pi;
cg = @(s, y) y^3;
initwt = 'Initial';
tlim = 7;
nmesh = int64(71);
work = zeros(1059, 1);
[yn, workOut, ifail] = d05bd(ck, cf, cg, initwt, tlim, nmesh, work);
yn, ifail
```
```

yn =

0
0.3162
0.4472
0.5477
0.6325
0.7071
0.7746
0.8367
0.8944
0.9487
1.0000
1.0488
1.0954
1.1402
1.1832
1.2247
1.2649
1.3038
1.3416
1.3784
1.4142
1.4491
1.4832
1.5166
1.5492
1.5811
1.6125
1.6432
1.6733
1.7029
1.7321
1.7607
1.7889
1.8166
1.8439
1.8708
1.8974
1.9235
1.9494
1.9748
2.0000
2.0248
2.0494
2.0736
2.0976
2.1213
2.1448
2.1679
2.1909
2.2136
2.2361
2.2583
2.2804
2.3022
2.3238
2.3452
2.3664
2.3875
2.4083
2.4290
2.4495
2.4698
2.4900
2.5100
2.5298
2.5495
2.5690
2.5884
2.6077
2.6268
2.6458

ifail =

0

```