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_fredholm2_split (d05aa)

## Purpose

nag_inteq_fredholm2_split (d05aa) solves a linear, nonsingular Fredholm equation of the second kind with a split kernel.

## Syntax

[f, c, ifail] = d05aa(lambda, a, b, k1, k2, g, n, ind)
[f, c, ifail] = nag_inteq_fredholm2_split(lambda, a, b, k1, k2, g, n, ind)

## Description

nag_inteq_fredholm2_split (d05aa) solves an integral equation of the form
 $fx-λ∫abkx,sfsds=gx$
for $a\le x\le b$, when the kernel $k$ is defined in two parts: $k={k}_{1}$ for $a\le s\le x$ and $k={k}_{2}$ for $x. The method used is that of El–Gendi (1969) for which, it is important to note, each of the functions ${k}_{1}$ and ${k}_{2}$ must be defined, smooth and nonsingular, for all $x$ and $s$ in the interval $\left[a,b\right]$.
An approximation to the solution $f\left(x\right)$ is found in the form of an $n$ term Chebyshev series $\underset{i=1}{\overset{n}{{\sum }^{\prime }}}{c}_{i}{T}_{i}\left(x\right)$, where ${}^{\prime }$ indicates that the first term is halved in the sum. The coefficients ${c}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, of this series are determined directly from approximate values ${f}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, of the function $f\left(x\right)$ at the first $n$ of a set of $m+1$ Chebyshev points:
 $xi=12a+b+b-acosi-1π/m, i=1,2,…,m+1.$
The values ${f}_{i}$ are obtained by solving simultaneous linear algebraic equations formed by applying a quadrature formula (equivalent to the scheme of Clenshaw and Curtis (1960)) to the integral equation at the above points.
In general $m=n-1$. However, if the kernel $k$ is centro-symmetric in the interval $\left[a,b\right]$, i.e., if $k\left(x,s\right)=k\left(a+b-x,a+b-s\right)$, then the function is designed to take advantage of this fact in the formation and solution of the algebraic equations. In this case, symmetry in the function $g\left(x\right)$ implies symmetry in the function $f\left(x\right)$. In particular, if $g\left(x\right)$ is even about the mid-point of the range of integration, then so also is $f\left(x\right)$, which may be approximated by an even Chebyshev series with $m=2n-1$. Similarly, if $g\left(x\right)$ is odd about the mid-point then $f\left(x\right)$ may be approximated by an odd series with $m=2n$.

## References

Clenshaw C W and Curtis A R (1960) A method for numerical integration on an automatic computer Numer. Math. 2 197–205
El–Gendi S E (1969) Chebyshev solution of differential, integral and integro-differential equations Comput. J. 12 282–287

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{lambda}$ – double scalar
The value of the parameter $\lambda$ of the integral equation.
2:     $\mathrm{a}$ – double scalar
$a$, the lower limit of integration.
3:     $\mathrm{b}$ – double scalar
$b$, the upper limit of integration.
Constraint: ${\mathbf{b}}>{\mathbf{a}}$.
4:     $\mathrm{k1}$ – function handle or string containing name of m-file
k1 must evaluate the kernel $k\left(x,s\right)={k}_{1}\left(x,s\right)$ of the integral equation for $a\le s\le x$.
[result] = k1(x, s)

Input Parameters

1:     $\mathrm{x}$ – double scalar
2:     $\mathrm{s}$ – double scalar
The values of $x$ and $s$ at which ${k}_{1}\left(x,s\right)$ is to be evaluated.

Output Parameters

1:     $\mathrm{result}$ – double scalar
The value of the kernel $k\left(x,s\right)={k}_{1}\left(x,s\right)$ evaluated at x and s.
5:     $\mathrm{k2}$ – function handle or string containing name of m-file
k2 must evaluate the kernel $k\left(x,s\right)={k}_{2}\left(x,s\right)$ of the integral equation for $x.
[result] = k2(x, s)

Input Parameters

1:     $\mathrm{x}$ – double scalar
2:     $\mathrm{s}$ – double scalar
The values of $x$ and $s$ at which ${k}_{2}\left(x,s\right)$ is to be evaluated.

Output Parameters

1:     $\mathrm{result}$ – double scalar
The value of the kernel $k\left(x,s\right)={k}_{2}\left(x,s\right)$ evaluated at x and s.
Note that the functions ${k}_{1}$ and ${k}_{2}$ must be defined, smooth and nonsingular for all $x$ and $s$ in the interval [$a,b$].
6:     $\mathrm{g}$ – function handle or string containing name of m-file
g must evaluate the function $g\left(x\right)$ for $a\le x\le b$.
[result] = g(x)

Input Parameters

1:     $\mathrm{x}$ – double scalar
The values of $x$ at which $g\left(x\right)$ is to be evaluated.

Output Parameters

1:     $\mathrm{result}$ – double scalar
The value of $g\left(x\right)$ evaluated at x.
7:     $\mathrm{n}$int64int32nag_int scalar
The number of terms in the Chebyshev series required to approximate $f\left(x\right)$.
Constraint: ${\mathbf{n}}\ge 1$.
8:     $\mathrm{ind}$int64int32nag_int scalar
Determines the forms of the kernel, $k\left(x,s\right)$, and the function $g\left(x\right)$.
${\mathbf{ind}}=0$
$k\left(x,s\right)$ is not centro-symmetric (or no account is to be taken of centro-symmetry).
${\mathbf{ind}}=1$
$k\left(x,s\right)$ is centro-symmetric and $g\left(x\right)$ is odd.
${\mathbf{ind}}=2$
$k\left(x,s\right)$ is centro-symmetric and $g\left(x\right)$ is even.
${\mathbf{ind}}=3$
$k\left(x,s\right)$ is centro-symmetric but $g\left(x\right)$ is neither odd nor even.
Constraint: ${\mathbf{ind}}=0$, $1$, $2$ or $3$.

None.

### Output Parameters

1:     $\mathrm{f}\left({\mathbf{n}}\right)$ – double array
The approximate values ${f}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$, of $f\left(x\right)$ evaluated at the first n of $m+1$ Chebyshev points ${x}_{i}$, (see Description).
If ${\mathbf{ind}}=0$ or $3$, $m={\mathbf{n}}-1$.
If ${\mathbf{ind}}=1$, $m=2×{\mathbf{n}}$.
If ${\mathbf{ind}}=2$, $m=2×{\mathbf{n}}-1$.
2:     $\mathrm{c}\left({\mathbf{n}}\right)$ – double array
The coefficients ${c}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$, of the Chebyshev series approximation to $f\left(x\right)$.
If ${\mathbf{ind}}=1$ this series contains polynomials of odd order only and if ${\mathbf{ind}}=2$ the series contains even order polynomials only.
3:     $\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{a}}\ge {\mathbf{b}}$ or ${\mathbf{n}}<1$.
${\mathbf{ifail}}=2$
A failure has occurred due to proximity to an eigenvalue. In general, if lambda is near an eigenvalue of the integral equation, the corresponding matrix will be nearly singular. In the special case, $m=1$, the matrix reduces to a zero-valued number.
${\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

No explicit error estimate is provided by the function but it is usually possible to obtain a good indication of the accuracy of the solution either
 (i) by examining the size of the later Chebyshev coefficients ${c}_{i}$, or (ii) by comparing the coefficients ${c}_{i}$ or the function values ${f}_{i}$ for two or more values of n.

The time taken by nag_inteq_fredholm2_split (d05aa) increases with n.
This function may be used to solve an equation with a continuous kernel by defining k1 and k2 to be identical.
This function may also be used to solve a Volterra equation by defining k2 (or k1) to be identically zero.

## Example

This example solves the equation
 $fx - ∫01 kx,s fs ds = 1 - 1 π2 sinπx$
where
 $kx,s = s1-x for ​ 0≤s≤x , x1-s for ​ x
Five terms of the Chebyshev series are sought, taking advantage of the centro-symmetry of the $k\left(x,s\right)$ and even nature of $g\left(x\right)$ about the mid-point of the range $\left[0,1\right]$.
The approximate solution at the point $x=0.1$ is calculated by calling nag_sum_chebyshev (c06dc).
```function d05aa_example

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

lambda = 1;
a = 0;
b = 1;
g = @(x) sin(pi*x)*(1-1/(pi*pi));
k1 = @(x, s) s*(1-x);
k2 = @(x, s) x*(1-s);
n = int64(5);
ind = int64(2);
[f, c, ifail] = d05aa(lambda, a, b, k1, k2, g, n, ind);

xval = 0.1;

% evaluate Chebyshev series at xval
s = int64(2);
[res, ifail] = c06dc(xval, a, b, c, s);
fprintf('Kernel is centro-symmetric and G is even so the solution is even\n')
fprintf('\nChebyshev coefficients:\n');
fprintf('%14.4f',c);
fprintf('\n\n x = %5.2f    Ans = %7.4f\n',xval,res);

```
```d05aa example results

Kernel is centro-symmetric and G is even so the solution is even

Chebyshev coefficients:
0.9440       -0.4994        0.0280       -0.0006        0.0000

x =  0.10    Ans =  0.3090
```