hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_inteq_fredholm2_smooth (d05ab)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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
fx-λabkx,sfsds=gx  
for the function fx in the range axb.
An approximation to the solution fx is found in the form of an n term Chebyshev series i=1nciTix, where  indicates that the first term is halved in the sum. The coefficients ci, for i=1,2,,n, of this series are determined directly from approximate values fi, for i=1,2,,n, of the function fx at the first n of a set of m+1 Chebyshev points
xi=12a+b+b-a×cosi-1×π/m,  i=1,2,,m+1.  
The values fi 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 fx. Thus if fx is symmetric (i.e., even) about the mid-point of the range a,b, it may be approximated by an even Chebyshev series with m=2n-1. Similarly, if fx 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.

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 kx,s of the integral equation over the square axb, asb.
[result] = k(x, s)

Input Parameters

1:     x – double scalar
2:     s – double scalar
The values of x and s at which kx,s is to be calculated.

Output Parameters

1:     result – double scalar
The value of the kernel kx,s evaluated at x and s.
2:     g – function handle or string containing name of m-file
g must compute the value of the function gx of the integral equation in the interval axb.
[result] = g(x)

Input Parameters

1:     x – double scalar
The value of x at which gx is to be calculated.

Output Parameters

1:     result – double scalar
The value of gx evaluated at x.
3:     lambda – double scalar
The value of the parameter λ of the integral equation.
4:     a – double scalar
a, the lower limit of integration.
5:     b – double scalar
b, the upper limit of integration.
Constraint: b>a.
6:     odorev – logical scalar
Indicates whether it is known that the solution fx 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 fx.
Constraint: n1.

Optional Input Parameters

None.

Output Parameters

1:     fn – double array
The approximate values fi, for i=1,2,,n, of the function fx at the first n of m+1 Chebyshev points (see Description), where
m=2n-1 if odorev=true and ev=true.
m=2n if odorev=true and ev=false.
m=n-1 if odorev=false.
2:     cn – double array
The coefficients ci, for i=1,2,,n, of the Chebyshev series approximation to fx. 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
ifail=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
On entry,ab or n<1.
   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 zero-valued number.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

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, or
(ii) by comparing the coefficients ci or the function values fi for two or more values of n.

Further Comments

The time taken by nag_inteq_fredholm2_smooth (d05ab) depends upon the value of n and upon the complexity of the kernel function kx,s.

Example

This example solves Love's equation:
fx+1π -11fs 1+ x-s 2 ds=1 .  
It will solve the slightly more general equation:
fx-λ ab kx,sfs ds=1  
where kx,s=α/α2+ x-s 2. The values λ=-1/π,a=-1,b=1,α=1 are used below.
It is evident from the symmetry of the given equation that fx is an even function. Advantage is taken of this fact both in the application of nag_inteq_fredholm2_smooth (d05ab), to obtain the fifxi and the ci, and in subsequent applications of nag_sum_chebyshev (c06dc) to obtain fx at selected points.
The program runs for n=5 and n=10.
function d05ab_example


fprintf('d05ab example results\n\n');

k = @(x, s) 1/(1+(x-s)*(x-s));
g = @(x) 1;
lambda = -0.3183;
a = -1;
b = 1;
odorev = true;
ev     = true;
xval = [0:0.25:1];
ss = int64(2);

for n = 5:5:10;
  in = int64(n);
  [f, c, ifail] = d05ab(k, g, lambda, a, b, odorev, ev, in);
  fprintf('\nResults for N = %2d\n\n', n);
  fprintf('Solution and coefficients on first %2d Chebyshev points\n',n);
  fprintf('  i           x             f(i)         c(i)\n');
  cheb(1:n,1) = cos(pi*(1:n)/(2*n-1));
  fprintf('%3d%15.5f%15.5f%15.5e\n', [[1:n]' cheb f c]');

  [chebr, ifail] = c06dc(xval, a, b, c, ss);

  fprintf('\nSolution on evenly spaced grid\n');
  fprintf('     x           f(x)\n');
  fprintf('%8.4f%15.5f\n',[xval' chebr]')

end


d05ab example results


Results for N =  5

Solution and coefficients on first  5 Chebyshev points
  i           x             f(i)         c(i)
  1        0.93969        0.75572    1.41520e+00
  2        0.76604        0.74534    4.93840e-02
  3        0.50000        0.71729   -1.04758e-03
  4        0.17365        0.68319   -2.32817e-04
  5       -0.17365        0.66051    2.08903e-05

Solution on evenly spaced grid
     x           f(x)
  0.0000        0.65742
  0.2500        0.66383
  0.5000        0.68319
  0.7500        0.71489
  1.0000        0.75572

Results for N = 10

Solution and coefficients on first 10 Chebyshev points
  i           x             f(i)         c(i)
  1        0.98636        0.75572    1.41520e+00
  2        0.94582        0.75336    4.93840e-02
  3        0.87947        0.74639   -1.04751e-03
  4        0.78914        0.73525   -2.32749e-04
  5        0.67728        0.72081    1.99856e-05
  6        0.54695        0.70452    9.86754e-07
  7        0.40170        0.68825   -2.37956e-07
  8        0.24549        0.67404    1.85810e-09
  9        0.08258        0.66361    2.44829e-09
 10       -0.08258        0.65812   -1.65268e-10

Solution on evenly spaced grid
     x           f(x)
  0.0000        0.65742
  0.2500        0.66384
  0.5000        0.68319
  0.7500        0.71489
  1.0000        0.75572

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015