NAG Library Routine Document
d05aaf
(fredholm2_split)
1
Purpose
d05aaf solves a linear, nonsingular Fredholm equation of the second kind with a split kernel.
2
Specification
Fortran Interface
Subroutine d05aaf ( 
lambda,
a,
b,
k1,
k2,
g,
f,
c,
n,
ind,
w1,
w2,
wd,
ldw1,
ldw2,
ifail) 
Integer, Intent (In)  :: 
n,
ind,
ldw1,
ldw2  Integer, Intent (Inout)  :: 
ifail  Real (Kind=nag_wp), External  :: 
k1,
k2,
g  Real (Kind=nag_wp), Intent (In)  :: 
lambda,
a,
b  Real (Kind=nag_wp), Intent (Inout)  :: 
w1(ldw1,ldw2),
w2(ldw2,4)  Real (Kind=nag_wp), Intent (Out)  :: 
f(n),
c(n),
wd(ldw2) 

C Header Interface
#include nagmk26.h
void 
d05aaf_ (
const double *lambda,
const double *a,
const double *b,
double (NAG_CALL *k1)(
const double *x,
const double *s),
double (NAG_CALL *k2)(
const double *x,
const double *s),
double (NAG_CALL *g)(
const double *x),
double f[],
double c[],
const Integer *n,
const Integer *ind,
double w1[],
double w2[],
double wd[],
const Integer *ldw1,
const Integer *ldw2,
Integer *ifail) 

3
Description
d05aaf solves an integral equation of the form
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<s\le b$. 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:
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=n1$. However, if the kernel $k$ is centrosymmetric in the interval $\left[a,b\right]$, i.e., if $k\left(x,s\right)=k\left(a+bx,a+bs\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 midpoint of the range of integration, then so also is $f\left(x\right)$, which may be approximated by an even Chebyshev series with $m=2n1$. Similarly, if $g\left(x\right)$ is odd about the midpoint 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 integrodifferential equations Comput. J. 12 282–287
5
Arguments
 1: $\mathbf{lambda}$ – Real (Kind=nag_wp)Input

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

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

On entry: $b$, the upper limit of integration.
Constraint:
${\mathbf{b}}>{\mathbf{a}}$.
 4: $\mathbf{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:
Fortran Interface
Real (Kind=nag_wp)  ::  k1  Real (Kind=nag_wp), Intent (In)  :: 
x,
s 

C Header Interface
#include nagmk26.h
double 
k1 (
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}_{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. Arguments denoted as
Input must
not be changed by this procedure.
Note: k1 should not return floatingpoint NaN (Not a Number) or infinity values, since these are not handled by
d05aaf. If your code inadvertently
does return any NaNs or infinities,
d05aaf is likely to produce unexpected results.
 5: $\mathbf{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<s\le b$.
The specification of
k2 is:
Fortran Interface
Real (Kind=nag_wp)  ::  k2  Real (Kind=nag_wp), Intent (In)  :: 
x,
s 

C Header Interface
#include nagmk26.h
double 
k2 (
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}_{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. Arguments denoted as
Input must
not be changed by this procedure.
Note: k2 should not return floatingpoint NaN (Not a Number) or infinity values, since these are not handled by
d05aaf. If your code inadvertently
does return any NaNs or infinities,
d05aaf is likely to produce unexpected results.
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: $\mathbf{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:
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 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. 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
d05aaf. If your code inadvertently
does return any NaNs or infinities,
d05aaf is likely to produce unexpected results.
 7: $\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
$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\times {\mathbf{n}}$.
If ${\mathbf{ind}}=2$, $m=2\times {\mathbf{n}}1$.
 8: $\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)$.
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: $\mathbf{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: $\mathbf{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 centrosymmetric (or no account is to be taken of centrosymmetry).
 ${\mathbf{ind}}=1$
 $k\left(x,s\right)$ is centrosymmetric and $g\left(x\right)$ is odd.
 ${\mathbf{ind}}=2$
 $k\left(x,s\right)$ is centrosymmetric and $g\left(x\right)$ is even.
 ${\mathbf{ind}}=3$
 $k\left(x,s\right)$ is centrosymmetric but $g\left(x\right)$ is neither odd nor even.
Constraint:
${\mathbf{ind}}=0$, $1$, $2$ or $3$.
 11: $\mathbf{w1}\left({\mathbf{ldw1}},{\mathbf{ldw2}}\right)$ – Real (Kind=nag_wp) arrayWorkspace
 12: $\mathbf{w2}\left({\mathbf{ldw2}},4\right)$ – Real (Kind=nag_wp) arrayWorkspace
 13: $\mathbf{wd}\left({\mathbf{ldw2}}\right)$ – Real (Kind=nag_wp) arrayWorkspace

 14: $\mathbf{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: $\mathbf{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\times {\mathbf{n}}+2$.
 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}}\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.
 ${\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 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. 
8
Parallelism and Performance
d05aaf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
d05aaf 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
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.
10
Example
This example solves the equation
where
Five terms of the Chebyshev series are sought, taking advantage of the centrosymmetry of the
$k\left(x,s\right)$ and even nature of
$g\left(x\right)$ about the midpoint of the range
$\left[0,1\right]$.
The approximate solution at the point
$x=0.1$ is calculated by calling
c06dcf.
10.1
Program Text
Program Text (d05aafe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (d05aafe.r)