Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_inteq_fredholm2_smooth (d05ab)

## Purpose

nag_inteq_fredholm2_smooth (d05ab) solves any linear nonsingular Fredholm integral equation of the second kind with a smooth kernel.

## Syntax

[f, c, ifail] = d05ab(k, g, lambda, a, b, odorev, ev, n)
[f, c, ifail] = nag_inteq_fredholm2_smooth(k, g, lambda, a, b, odorev, ev, n)

## Description

nag_inteq_fredholm2_smooth (d05ab) uses the method of El–Gendi (1969) to solve an integral equation of the form
 b f(x) − λ ∫ k(x,s)f(s)ds = g(x) a
$f(x)-λ∫abk(x,s)f(s)ds=g(x)$
for the function f(x)$f\left(x\right)$ in the range axb$a\le x\le b$.
An approximation to the solution f(x)$f\left(x\right)$ is found in the form of an n$n$ term Chebyshev series i = 1nciTi(x)$\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 ci${c}_{\mathit{i}}$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$, of this series are determined directly from approximate values fi${f}_{\mathit{i}}$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$, of the function f(x)$f\left(x\right)$ at the first n$n$ of a set of m + 1$m+1$ Chebyshev points
 xi = (1/2)(a + b + (b − a) × cos[(i − 1) × π / m]),  i = 1,2, … ,m + 1. $xi=12(a+b+(b-a)×cos[(i-1)×π/m]), i=1,2,…,m+1.$
The values fi${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$m=n-1$. However, advantage may be taken of any prior knowledge of the symmetry of f(x)$f\left(x\right)$. Thus if f(x)$f\left(x\right)$ is symmetric (i.e., even) about the mid-point of the range (a,b)$\left(a,b\right)$, it may be approximated by an even Chebyshev series with m = 2n1$m=2n-1$. Similarly, if f(x)$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$m=2n$.

## 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

## Parameters

### Compulsory Input Parameters

1:     k – function handle or string containing name of m-file
k must compute the value of the kernel k(x,s)$k\left(x,s\right)$ of the integral equation over the square axb$a\le x\le b$, asb$a\le s\le b$.
[result] = k(x, s)

Input Parameters

1:     x – double scalar
2:     s – double scalar
The values of x$x$ and s$s$ at which k(x,s)$k\left(x,s\right)$ is to be calculated.

Output Parameters

1:     result – double scalar
The result of the function.
2:     g – function handle or string containing name of m-file
g must compute the value of the function g(x)$g\left(x\right)$ of the integral equation in the interval axb$a\le x\le b$.
[result] = g(x)

Input Parameters

1:     x – double scalar
The value of x$x$ at which g(x)$g\left(x\right)$ is to be calculated.

Output Parameters

1:     result – double scalar
The result of the function.
3:     lambda – double scalar
The value of the parameter λ$\lambda$ of the integral equation.
4:     a – double scalar
a$a$, the lower limit of integration.
5:     b – double scalar
b$b$, the upper limit of integration.
Constraint: b > a${\mathbf{b}}>{\mathbf{a}}$.
6:     odorev – logical scalar
Indicates whether it is known that the solution f(x)$f\left(x\right)$ is odd or even about the mid-point 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 – logical scalar
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 – int64int32nag_int scalar
The number of terms in the Chebyshev series which approximates the solution f(x)$f\left(x\right)$.
Constraint: n1${\mathbf{n}}\ge 1$.

None.

### Input Parameters Omitted from the MATLAB Interface

cm f1 wk ldcm nt2p1

### Output Parameters

1:     f(n) – double array
The approximate values fi${f}_{\mathit{i}}$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,{\mathbf{n}}$, of the function f(x)$f\left(x\right)$ at the first n of m + 1$m+1$ Chebyshev points (see Section [Description]), where
 m = 2n − 1$m=2{\mathbf{n}}-1$ if odorev = true${\mathbf{odorev}}=\mathbf{true}$ and ev = true${\mathbf{ev}}=\mathbf{true}$. m = 2n$m=2{\mathbf{n}}$ if odorev = true${\mathbf{odorev}}=\mathbf{true}$ and ev = false${\mathbf{ev}}=\mathbf{false}$. m = n − 1$m={\mathbf{n}}-1$ if odorev = false${\mathbf{odorev}}=\mathbf{false}$.
2:     c(n) – double array
The coefficients ci${c}_{\mathit{i}}$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,{\mathbf{n}}$, of the Chebyshev series approximation to f(x)$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.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, a ≥ b${\mathbf{a}}\ge {\mathbf{b}}$ or n < 1${\mathbf{n}}<1$.
ifail = 2${\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$m=1$, the matrix reduces to a zero-valued number.

## Accuracy

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
 (i) by examining the size of the later Chebyshev coefficients ci${c}_{i}$, or (ii) by comparing the coefficients ci${c}_{i}$ or the function values fi${f}_{i}$ for two or more values of n.

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

## Example

```function nag_inteq_fredholm2_smooth_example
k = @(x, s) 1/(1+(x-s)*(x-s));
g = @(x) 1;
lambda = -0.3183;
a = -1;
b = 1;
odorev = true;
ev = true;
n = int64(5);
[f, c, ifail] = nag_inteq_fredholm2_smooth(k, g, lambda, a, b, odorev, ev, n)
```
```

f =

0.7557
0.7453
0.7173
0.6832
0.6605

c =

1.4152
0.0494
-0.0010
-0.0002
0.0000

ifail =

0

```
```function d05ab_example
k = @(x, s) 1/(1+(x-s)*(x-s));
g = @(x) 1;
lambda = -0.3183;
a = -1;
b = 1;
odorev = true;
ev = true;
n = int64(5);
[f, c, ifail] = d05ab(k, g, lambda, a, b, odorev, ev, n)
```
```

f =

0.7557
0.7453
0.7173
0.6832
0.6605

c =

1.4152
0.0494
-0.0010
-0.0002
0.0000

ifail =

0

```