# NAG CL Interfaced05abc (fredholm2_​smooth)

Settings help

CL Name Style:

## 1Purpose

d05abc solves any linear nonsingular Fredholm integral equation of the second kind with a smooth kernel.

## 2Specification

 #include
void  d05abc (double lambda, double a, double b, Integer n,
 double (*k)(double x, double s, Nag_Comm *comm),
 double (*g)(double x, Nag_Comm *comm),
Nag_Boolean odorev, Nag_Boolean ev, double f[], double c[], Nag_Comm *comm, NagError *fail)
The function may be called by the names: d05abc or nag_inteq_fredholm2_smooth.

## 3Description

d05abc uses the method of El–Gendi (1969) to solve an integral equation of the form
 $f(x)-λ∫abk(x,s)f(s)ds=g(x)$
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
 $xi=12(a+b+(b-a)×cos[(i-1)×π/m]), i=1,2,…,m+1.$
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=n-1$. 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 mid-point of the range $\left(a,b\right)$, it may be approximated by an even Chebyshev series with $m=2n-1$. Similarly, if $f\left(x\right)$ is anti-symmetric (i.e., odd) about the mid-point of the range of integration, it may be approximated by an odd Chebyshev series with $m=2n$.

## 4References

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

## 5Arguments

1: $\mathbf{lambda}$double Input
On entry: the value of the parameter $\lambda$ of the integral equation.
2: $\mathbf{a}$double Input
On entry: $a$, the lower limit of integration.
3: $\mathbf{b}$double Input
On entry: $b$, the upper limit of integration.
Constraint: ${\mathbf{b}}>{\mathbf{a}}$.
4: $\mathbf{n}$Integer Input
On entry: the number of terms in the Chebyshev series which approximates the solution $f\left(x\right)$.
Constraint: ${\mathbf{n}}\ge 1$.
5: $\mathbf{k}$function, supplied by the user External Function
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:
 double k (double x, double s, Nag_Comm *comm)
1: $\mathbf{x}$double Input
2: $\mathbf{s}$double Input
On entry: the values of $x$ and $s$ at which $k\left(x,s\right)$ is to be calculated.
3: $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to k.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling d05abc you may allocate memory and initialize these pointers with various quantities for use by k when called from d05abc (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
Note: k should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d05abc. If your code inadvertently does return any NaNs or infinities, d05abc is likely to produce unexpected results.
6: $\mathbf{g}$function, supplied by the user External Function
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:
 double g (double x, Nag_Comm *comm)
1: $\mathbf{x}$double Input
On entry: the value of $x$ at which $g\left(x\right)$ is to be calculated.
2: $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to g.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling d05abc you may allocate memory and initialize these pointers with various quantities for use by g when called from d05abc (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
Note: g should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d05abc. If your code inadvertently does return any NaNs or infinities, d05abc is likely to produce unexpected results.
7: $\mathbf{odorev}$Nag_Boolean Input
On entry: indicates whether it is known that the solution $f\left(x\right)$ is odd or even about the mid-point of the range of integration. If odorev is Nag_TRUE then an odd or even solution is sought depending upon the value of ev.
8: $\mathbf{ev}$Nag_Boolean Input
On entry: is ignored if odorev is Nag_FALSE. Otherwise, if ev is Nag_TRUE, an even solution is sought, whilst if ev is Nag_FALSE, an odd solution is sought.
9: $\mathbf{f}\left[{\mathbf{n}}\right]$double Output
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{Nag_TRUE}$ and ${\mathbf{ev}}=\mathrm{Nag_TRUE}$. $m=2{\mathbf{n}}$ if ${\mathbf{odorev}}=\mathrm{Nag_TRUE}$ and ${\mathbf{ev}}=\mathrm{Nag_FALSE}$. $m={\mathbf{n}}-1$ if ${\mathbf{odorev}}=\mathrm{Nag_FALSE}$.
10: $\mathbf{c}\left[{\mathbf{n}}\right]$double Output
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 Nag_TRUE, this series contains polynomials of even order only or of odd order only, according to ev being Nag_TRUE or Nag_FALSE respectively.
11: $\mathbf{comm}$Nag_Comm *
The NAG communication argument (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
12: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_EIGENVALUES
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 zero-valued number.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL_2
On entry, ${\mathbf{a}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{b}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{b}}>{\mathbf{a}}$.

## 7Accuracy

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

## 8Parallelism and Performance

d05abc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
d05abc 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The time taken by d05abc depends upon the value of n and upon the complexity of the kernel function $k\left(x,s\right)$.

## 10Example

This example solves Love's equation:
 $f(x)+1π ∫−11f(s) 1+ (x-s) 2 ds=1 .$
It will solve the slightly more general equation:
 $f(x)-λ ∫ab k(x,s)f(s) ds=1$
where $k\left(x,s\right)=\alpha /\left({\alpha }^{2}+{\left(x-s\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 d05abc, to obtain the ${f}_{i}\simeq f\left({x}_{i}\right)$ and the ${c}_{i}$, and in subsequent applications of c06dcc to obtain $f\left(x\right)$ at selected points.
The program runs for ${\mathbf{n}}=5$ and ${\mathbf{n}}=10$.

### 10.1Program Text

Program Text (d05abce.c)

None.

### 10.3Program Results

Program Results (d05abce.r)