d05 Chapter Contents
d05 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_inteq_fredholm2_split (d05aac)

## 1  Purpose

nag_inteq_fredholm2_split (d05aac) solves a linear, nonsingular Fredholm equation of the second kind with a split kernel.

## 2  Specification

 #include #include
void  nag_inteq_fredholm2_split (double lambda, double a, double b, Integer n,
 double (*k1)(double x, double s, Nag_Comm *comm),
 double (*k2)(double x, double s, Nag_Comm *comm),
 double (*g)(double x, Nag_Comm *comm),
Nag_KernelForm kform, double f[], double c[], Nag_Comm *comm, NagError *fail)

## 3  Description

nag_inteq_fredholm2_split (d05aac) 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 function 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  Arguments

On entry: the value of the parameter $\lambda$ of the integral equation.
On entry: $a$, the lower limit of integration.
3:     bdoubleInput
On entry: $b$, the upper limit of integration.
Constraint: ${\mathbf{b}}>{\mathbf{a}}$.
4:     nIntegerInput
On entry: the number of terms in the Chebyshev series required to approximate $f\left(x\right)$.
Constraint: ${\mathbf{n}}\ge 1$.
5:     k1function, supplied by the userExternal Function
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:
 double k1 (double x, double s, Nag_Comm *comm)
1:     xdoubleInput
2:     sdoubleInput
On entry: the values of $x$ and $s$ at which ${k}_{1}\left(x,s\right)$ is to be evaluated.
3:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to k1.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_inteq_fredholm2_split (d05aac) you may allocate memory and initialize these pointers with various quantities for use by k1 when called from nag_inteq_fredholm2_split (d05aac) (see Section 3.2.1 in the Essential Introduction).
6:     k2function, supplied by the userExternal Function
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:
 double k2 (double x, double s, Nag_Comm *comm)
1:     xdoubleInput
2:     sdoubleInput
On entry: the values of $x$ and $s$ at which ${k}_{2}\left(x,s\right)$ is to be evaluated.
3:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to k2.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_inteq_fredholm2_split (d05aac) you may allocate memory and initialize these pointers with various quantities for use by k2 when called from nag_inteq_fredholm2_split (d05aac) (see Section 3.2.1 in the Essential Introduction).
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$].
7:     gfunction, supplied by the userExternal Function
g must evaluate the function $g\left(x\right)$ for $a\le x\le b$.
The specification of g is:
 double g (double x, Nag_Comm *comm)
1:     xdoubleInput
On entry: the values of $x$ at which $g\left(x\right)$ is to be evaluated.
2:     commNag_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 nag_inteq_fredholm2_split (d05aac) you may allocate memory and initialize these pointers with various quantities for use by g when called from nag_inteq_fredholm2_split (d05aac) (see Section 3.2.1 in the Essential Introduction).
8:     kformNag_KernelFormInput
On entry: determines the forms of the kernel, $k\left(x,s\right)$, and the function $g\left(x\right)$.
${\mathbf{kform}}=\mathrm{Nag_NoCentroSymm}$
$k\left(x,s\right)$ is not centro-symmetric (or no account is to be taken of centro-symmetry).
${\mathbf{kform}}=\mathrm{Nag_CentroSymmOdd}$
$k\left(x,s\right)$ is centro-symmetric and $g\left(x\right)$ is odd.
${\mathbf{kform}}=\mathrm{Nag_CentroSymmEven}$
$k\left(x,s\right)$ is centro-symmetric and $g\left(x\right)$ is even.
${\mathbf{kform}}=\mathrm{Nag_CentroSymmNeither}$
$k\left(x,s\right)$ is centro-symmetric but $g\left(x\right)$ is neither odd nor even.
Constraint: ${\mathbf{kform}}=\mathrm{Nag_NoCentroSymm}$, $\mathrm{Nag_CentroSymmOdd}$, $\mathrm{Nag_CentroSymmEven}$ or $\mathrm{Nag_CentroSymmNeither}$.
9:     f[n]doubleOutput
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{kform}}=\mathrm{Nag_NoCentroSymm}$ or $\mathrm{Nag_CentroSymmNeither}$, $m={\mathbf{n}}-1$.
If ${\mathbf{kform}}=\mathrm{Nag_CentroSymmOdd}$, $m=2×{\mathbf{n}}$.
If ${\mathbf{kform}}=\mathrm{Nag_CentroSymmEven}$, $m=2×{\mathbf{n}}-1$.
10:   c[n]doubleOutput
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{kform}}=\mathrm{Nag_CentroSymmOdd}$ this series contains polynomials of odd order only and if ${\mathbf{kform}}=\mathrm{Nag_CentroSymmEven}$ the series contains even order polynomials only.
11:   commNag_Comm *Communication Structure
The NAG communication argument (see Section 3.2.1.1 in the Essential Introduction).
12:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_EIGENVALUES
A failure has occurred due to proximity of an eigenvalue.
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.
NE_REAL_2
On entry, ${\mathbf{a}}=〈\mathit{\text{value}}〉$ and ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{b}}>{\mathbf{a}}$.

## 7  Accuracy

No explicit error estimate is provided by the function 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 nag_inteq_fredholm2_split (d05aac) increases with n.
This function may be used to solve an equation with a continuous kernel by defining k1 and k2 to be identical.
This function 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 nag_sum_cheby_series (c06dcc).

### 9.1  Program Text

Program Text (d05aace.c)

None.

### 9.3  Program Results

Program Results (d05aace.r)