NAG Library Routine Document
d05abf (fredholm2_smooth)
1
Purpose
d05abf solves any linear nonsingular Fredholm integral equation of the second kind with a smooth kernel.
2
Specification
Fortran Interface
Subroutine d05abf ( 
k, g, lambda, a, b, odorev, ev, n, cm, f1, wk, ldcm, nt2p1, f, c, ifail) 
Integer, Intent (In)  ::  n, ldcm, nt2p1  Integer, Intent (Inout)  ::  ifail  Real (Kind=nag_wp), External  ::  k, g  Real (Kind=nag_wp), Intent (In)  ::  lambda, a, b  Real (Kind=nag_wp), Intent (Inout)  ::  cm(ldcm,ldcm), f1(ldcm,1)  Real (Kind=nag_wp), Intent (Out)  ::  wk(2,nt2p1), f(n), c(n)  Logical, Intent (In)  ::  odorev, ev 

C Header Interface
#include <nagmk26.h>
void 
d05abf_ ( double (NAG_CALL *k)(const double *x, const double *s), double (NAG_CALL *g)(const double *x), const double *lambda, const double *a, const double *b, const logical *odorev, const logical *ev, const Integer *n, double cm[], double f1[], double wk[], const Integer *ldcm, const Integer *nt2p1, double f[], double c[], Integer *ifail) 

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
Arguments
 1: $\mathbf{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:
Fortran Interface
Real (Kind=nag_wp)  ::  k  Real (Kind=nag_wp), Intent (In)  ::  x, s 

C Header Interface
#include <nagmk26.h>
double 
k (const double *x, const double *s) 

 1: $\mathbf{x}$ – Real (Kind=nag_wp)Input
 2: $\mathbf{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. Arguments denoted as
Input must
not be changed by this procedure.
Note: k should not return floatingpoint NaN (Not a Number) or infinity values, since these are not handled by
d05abf. If your code inadvertently
does return any NaNs or infinities,
d05abf is likely to produce unexpected results.
 2: $\mathbf{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:
Fortran Interface
Real (Kind=nag_wp)  ::  g  Real (Kind=nag_wp), Intent (In)  ::  x 

C Header Interface
#include <nagmk26.h>
double 
g (const double *x) 

 1: $\mathbf{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. Arguments denoted as
Input must
not be changed by this procedure.
Note: g should not return floatingpoint NaN (Not a Number) or infinity values, since these are not handled by
d05abf. If your code inadvertently
does return any NaNs or infinities,
d05abf is likely to produce unexpected results.
 3: $\mathbf{lambda}$ – Real (Kind=nag_wp)Input

On entry: the value of the parameter $\lambda $ of the integral equation.
 4: $\mathbf{a}$ – Real (Kind=nag_wp)Input

On entry: $a$, the lower limit of integration.
 5: $\mathbf{b}$ – Real (Kind=nag_wp)Input

On entry: $b$, the upper limit of integration.
Constraint:
${\mathbf{b}}>{\mathbf{a}}$.
 6: $\mathbf{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: $\mathbf{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: $\mathbf{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: $\mathbf{cm}\left({\mathbf{ldcm}},{\mathbf{ldcm}}\right)$ – Real (Kind=nag_wp) arrayWorkspace
 10: $\mathbf{f1}\left({\mathbf{ldcm}},1\right)$ – Real (Kind=nag_wp) arrayWorkspace
 11: $\mathbf{wk}\left(2,{\mathbf{nt2p1}}\right)$ – Real (Kind=nag_wp) arrayWorkspace

 12: $\mathbf{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: $\mathbf{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: $\mathbf{f}\left({\mathbf{n}}\right)$ – 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: $\mathbf{c}\left({\mathbf{n}}\right)$ – 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: $\mathbf{ifail}$ – IntegerInput/Output

On entry:
ifail must be set to
$0$,
$1\text{or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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}}=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{a}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{b}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{b}}>{\mathbf{a}}$.
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge 1$.
 ${\mathbf{ifail}}=2$

A failure has occurred due to proximity of 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.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{ifail}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
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. 
8
Parallelism and Performance
d05abf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
d05abf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
The time taken by
d05abf depends upon the value of
n and upon the complexity of the kernel function
$k\left(x,s\right)$.
10
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$.
10.1
Program Text
Program Text (d05abfe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (d05abfe.r)