D05 Chapter Contents
D05 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD05AAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D05AAF solves a linear, nonsingular Fredholm equation of the second kind with a split kernel.

## 2  Specification

 SUBROUTINE D05AAF ( LAMBDA, A, B, K1, K2, G, F, C, N, IND, W1, W2, WD, LDW1, LDW2, IFAIL)
 INTEGER N, IND, LDW1, LDW2, IFAIL REAL (KIND=nag_wp) LAMBDA, A, B, K1, K2, G, F(N), C(N), W1(LDW1,LDW2), W2(LDW2,4), WD(LDW2) EXTERNAL K1, K2, G

## 3  Description

D05AAF 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 routine 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$.

## 4  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

## 5  Parameters

1:     LAMBDA – REAL (KIND=nag_wp)Input
On entry: the value of the parameter $\lambda$ of the integral equation.
2:     A – REAL (KIND=nag_wp)Input
On entry: $a$, the lower limit of integration.
3:     B – REAL (KIND=nag_wp)Input
On entry: $b$, the upper limit of integration.
Constraint: ${\mathbf{B}}>{\mathbf{A}}$.
4:     K1 – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
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$.
The specification of K1 is:
 FUNCTION K1 ( X, S)
 REAL (KIND=nag_wp) K1
 REAL (KIND=nag_wp) X, S
1:     X – REAL (KIND=nag_wp)Input
2:     S – REAL (KIND=nag_wp)Input
On entry: the values of $x$ and $s$ at which ${k}_{1}\left(x,s\right)$ is to be evaluated.
K1 must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05AAF is called. Parameters denoted as Input must not be changed by this procedure.
5:     K2 – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
K2 must evaluate the kernel $k\left(x,s\right)={k}_{2}\left(x,s\right)$ of the integral equation for $x.
The specification of K2 is:
 FUNCTION K2 ( X, S)
 REAL (KIND=nag_wp) K2
 REAL (KIND=nag_wp) X, S
1:     X – REAL (KIND=nag_wp)Input
2:     S – REAL (KIND=nag_wp)Input
On entry: the values of $x$ and $s$ at which ${k}_{2}\left(x,s\right)$ is to be evaluated.
K2 must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05AAF is called. Parameters denoted as Input must not be changed by this procedure.
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:     G – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
G must evaluate the function $g\left(x\right)$ for $a\le x\le b$.
The specification of G is:
 FUNCTION G ( X)
 REAL (KIND=nag_wp) G
 REAL (KIND=nag_wp) X
1:     X – REAL (KIND=nag_wp)Input
On entry: the values of $x$ at which $g\left(x\right)$ is to be evaluated.
G must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05AAF is called. Parameters denoted as Input must not be changed by this procedure.
7:     F(N) – REAL (KIND=nag_wp) arrayOutput
On exit: 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 Section 3).
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$.
8:     C(N) – REAL (KIND=nag_wp) arrayOutput
On exit: 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.
9:     N – INTEGERInput
On entry: the number of terms in the Chebyshev series required to approximate $f\left(x\right)$.
Constraint: ${\mathbf{N}}\ge 1$.
10:   IND – INTEGERInput
On entry: 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$.
11:   W1(LDW1,LDW2) – REAL (KIND=nag_wp) arrayWorkspace
12:   W2(LDW2,$4$) – REAL (KIND=nag_wp) arrayWorkspace
13:   WD(LDW2) – REAL (KIND=nag_wp) arrayWorkspace
14:   LDW1 – INTEGERInput
On entry: the first dimension of the array W1 as declared in the (sub)program from which D05AAF is called.
Constraint: ${\mathbf{LDW1}}\ge {\mathbf{N}}$.
15:   LDW2 – INTEGERInput
On entry: the second dimension of the array W1 and the first dimension of the array W2 and the dimension of the array WD as declared in the (sub)program from which D05AAF is called.
Constraint: ${\mathbf{LDW2}}\ge 2×{\mathbf{N}}+2$.
16:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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{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.

## 7  Accuracy

No explicit error estimate is provided by the routine 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 D05AAF increases with N.
This routine may be used to solve an equation with a continuous kernel by defining K1 and K2 to be identical.
This routine may also be used to solve a Volterra equation by defining K2 (or K1) to be identically zero.

## 9  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 C06DCF.

### 9.1  Program Text

Program Text (d05aafe.f90)

None.

### 9.3  Program Results

Program Results (d05aafe.r)