NAG Library Routine Document
D05ABF
1 Purpose
D05ABF solves any linear nonsingular Fredholm integral equation of the second kind with a smooth kernel.
2 Specification
SUBROUTINE D05ABF ( 
K, G, LAMBDA, A, B, ODOREV, EV, N, CM, F1, WK, LDCM, NT2P1, F, C, IFAIL) 
INTEGER 
N, LDCM, NT2P1, IFAIL 
REAL (KIND=nag_wp) 
K, G, LAMBDA, A, B, CM(LDCM,LDCM), F1(LDCM,1), WK(2,NT2P1), F(N), C(N) 
LOGICAL 
ODOREV, EV 
EXTERNAL 
K, G 

3 Description
D05ABF uses the method of
El–Gendi (1969) to solve an integral equation of the form
for the function
$f\left(x\right)$ in the range
$a\le x\le b$.
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
The values
${f}_{i}$ are obtained by solving a set of simultaneous linear algebraic equations formed by applying a quadrature formula (equivalent to the scheme of
Clenshaw and Curtis (1960)) to the integral equation at each of the above points.
In general $m=n1$. However, advantage may be taken of any prior knowledge of the symmetry of $f\left(x\right)$. Thus if $f\left(x\right)$ is symmetric (i.e., even) about the midpoint of the range $\left(a,b\right)$, it may be approximated by an even Chebyshev series with $m=2n1$. Similarly, if $f\left(x\right)$ is antisymmetric (i.e., odd) about the midpoint of the range of integration, it may be approximated by an odd Chebyshev 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 integrodifferential equations Comput. J. 12 282–287
5 Parameters
 1: K – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
K must compute the value of the kernel
$k\left(x,s\right)$ of the integral equation over the square
$a\le x\le b$,
$a\le s\le b$.
The specification of
K is:
 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\left(x,s\right)$ is to be calculated.
K must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05ABF is called. Parameters denoted as
Input must
not be changed by this procedure.
 2: G – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
G must compute the value of the function
$g\left(x\right)$ of the integral equation in the interval
$a\le x\le b$.
The specification of
G is:
 1: X – REAL (KIND=nag_wp)Input
On entry: the value of $x$ at which $g\left(x\right)$ is to be calculated.
G must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D05ABF is called. Parameters denoted as
Input must
not be changed by this procedure.
 3: LAMBDA – REAL (KIND=nag_wp)Input
On entry: the value of the parameter $\lambda $ of the integral equation.
 4: A – REAL (KIND=nag_wp)Input
On entry: $a$, the lower limit of integration.
 5: B – REAL (KIND=nag_wp)Input
On entry: $b$, the upper limit of integration.
Constraint:
${\mathbf{B}}>{\mathbf{A}}$.
 6: ODOREV – LOGICALInput
On entry: indicates whether it is known that the solution
$f\left(x\right)$ is odd or even about the midpoint of the range of integration. If
ODOREV is .TRUE. then an odd or even solution is sought depending upon the value of
EV.
 7: EV – LOGICALInput
On entry: is ignored if
ODOREV is .FALSE.. Otherwise, if
EV is .TRUE., an even solution is sought, whilst if
EV is .FALSE., an odd solution is sought.
 8: N – INTEGERInput
On entry: the number of terms in the Chebyshev series which approximates the solution $f\left(x\right)$.
Constraint:
${\mathbf{N}}\ge 1$.
 9: CM(LDCM,LDCM) – REAL (KIND=nag_wp) arrayWorkspace
 10: F1(LDCM,$1$) – REAL (KIND=nag_wp) arrayWorkspace
 11: WK($2$,NT2P1) – REAL (KIND=nag_wp) arrayWorkspace
 12: LDCM – INTEGERInput
On entry: the first dimension of the arrays
CM and
F1 and the second dimension of the array
CM as declared in the (sub)program from which D05ABF is called.
Constraint:
${\mathbf{LDCM}}\ge {\mathbf{N}}$.
 13: NT2P1 – INTEGERInput
On entry: the second dimension of the array
WK as declared in the (sub)program from which D05ABF is called. The value
$2\times {\mathbf{N}}+1$.
 14: F(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the approximate values
${f}_{\mathit{i}}$, for
$\mathit{i}=1,2,\dots ,{\mathbf{N}}$, of the function
$f\left(x\right)$ at the first
N of
$m+1$ Chebyshev points (see
Section 3), where
$m=2{\mathbf{N}}1$ 
if ${\mathbf{ODOREV}}=\mathrm{.TRUE.}$ and ${\mathbf{EV}}=\mathrm{.TRUE.}$. 
$m=2{\mathbf{N}}$ 
if ${\mathbf{ODOREV}}=\mathrm{.TRUE.}$ and ${\mathbf{EV}}=\mathrm{.FALSE.}$. 
$m={\mathbf{N}}1$ 
if ${\mathbf{ODOREV}}=\mathrm{.FALSE.}$. 
 15: 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)$. When
ODOREV is .TRUE., this series contains polynomials of even order only or of odd order only, according to
EV being .TRUE. or .FALSE. respectively.
 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 zerovalued number.
7 Accuracy
No explicit error estimate is provided by the routine but it is 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 D05ABF depends upon the value of
N and upon the complexity of the kernel function
$k\left(x,s\right)$.
9 Example
This example solves Love's equation:
It will solve the slightly more general equation:
where
$k\left(x,s\right)=\alpha /\left({\alpha}^{2}+{\left(xs\right)}^{2}\right)$. The values
$\lambda =1/\pi ,a=1,b=1,\alpha =1$ are used below.
It is evident from the symmetry of the given equation that
$f\left(x\right)$ is an even function. Advantage is taken of this fact both in the application of D05ABF, to obtain the
${f}_{i}\simeq f\left({x}_{i}\right)$ and the
${c}_{i}$, and in subsequent applications of
C06DCF to obtain
$f\left(x\right)$ at selected points.
The program runs for ${\mathbf{N}}=5$ and ${\mathbf{N}}=10$.
9.1 Program Text
Program Text (d05abfe.f90)
9.2 Program Data
None.
9.3 Program Results
Program Results (d05abfe.r)