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_ode_bvp_ps_lin_grid_vals (d02uw)

Purpose

nag_ode_bvp_ps_lin_grid_vals (d02uw) interpolates from a set of function values on a supplied grid onto a set of values for a uniform grid on the same range. The interpolation is performed using barycentric Lagrange interpolation. nag_ode_bvp_ps_lin_grid_vals (d02uw) is primarily a utility function to map a set of function values specified on a Chebyshev Gauss–Lobatto grid onto a uniform grid.

Syntax

[xip, fip, ifail] = d02uw(n, nip, x, f)
[xip, fip, ifail] = nag_ode_bvp_ps_lin_grid_vals(n, nip, x, f)

Description

nag_ode_bvp_ps_lin_grid_vals (d02uw) interpolates from a set of n + 1n+1 function values, f(xi)f(xi), on a supplied grid, xixi, for i = 0,1,,ni=0,1,,n, onto a set of mm values, (j)f^(x^j), on a uniform grid, jx^j, for j = 1,2,,mj=1,2,,m. The image x^ has the same range as xx, so that j = xmin + ((j1) / (m1)) × (xmaxxmin) x^j = xmin + ( (j-1) / (m-1) ) × ( xmax - xmin ) , for j = 1,2,,mj=1,2,,m. The interpolation is performed using barycentric Lagrange interpolation as described in Berrut and Trefethen (2004).
nag_ode_bvp_ps_lin_grid_vals (d02uw) is primarily a utility function to map a set of function values specified on a Chebyshev Gauss–Lobatto grid computed by nag_ode_bvp_ps_lin_cgl_grid (d02uc) onto an evenly-spaced grid with the same range as the original grid.

References

Berrut J P and Trefethen L N (2004) Barycentric lagrange interpolation SIAM Rev. 46(3) 501–517

Parameters

Compulsory Input Parameters

1:     n – int64int32nag_int scalar
nn, where the number of grid points for the input data is n + 1n+1.
Constraint: n > 0n>0 and n is even.
2:     nip – int64int32nag_int scalar
The number, mm, of grid points in the uniform mesh x^ onto which function values are interpolated. If nip = 1nip=1 then on successful exit from nag_ode_bvp_ps_lin_grid_vals (d02uw), fip(1)fip1 will contain the value f(xn)f(xn).
Constraint: nip > 0nip>0.
3:     x(n + 1n+1) – double array
The grid points, xixi, for i = 0,1,,ni=0,1,,n, at which the function is specified.
Usually this should be the array of Chebyshev Gauss–Lobatto points returned in nag_ode_bvp_ps_lin_cgl_grid (d02uc).
4:     f(n + 1n+1) – double array
The function values, f(xi)f(xi), for i = 0,1,,ni=0,1,,n.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     xip(nip) – double array
The evenly-spaced grid points, jx^j, for j = 1,2,,mj=1,2,,m.
2:     fip(nip) – double array
The set of interpolated values (j)f^(x^j), for j = 1,2,,mj=1,2,,m. Here (j)f(x = j)f^(x^j)f(x=x^j).
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

  ifail = 1ifail=1
Constraint: n > 0n>0.
Constraint: n is even.
  ifail = 2ifail=2
Constraint: nip > 0nip>0.

Accuracy

nag_ode_bvp_ps_lin_grid_vals (d02uw) is intended, primarily, for use with Chebyshev Gauss–Lobatto input grids. For such input grids and for well-behaved functions (no discontinuities, peaks or cusps), the accuracy should be a small multiple of machine precision.

Further Comments

None.

Example

function nag_ode_bvp_ps_lin_grid_vals_example
n   = int64(64);
nip = int64(17);
a = -1;
b =  1;



% Set up solution grid
[x, ifail] = nag_ode_bvp_ps_lin_cgl_grid(n, a, b);

% Set up problem right hand sides for grid
f = x + cos(5*x);

% Solve on equally spaced grid
[xip, fip, ifail] = nag_ode_bvp_ps_lin_grid_vals(n, nip, x, f);

% Print solution
fprintf('\nNumerical solution F\n');
fprintf('      x          F\n');
for i=1:17
  fprintf('%10.4f %10.4f \n', xip(i), fip(i));
end
 

Numerical solution F
      x          F
   -1.0000    -0.7163 
   -0.8750    -1.2060 
   -0.7500    -1.5706 
   -0.6250    -1.6249 
   -0.5000    -1.3011 
   -0.3750    -0.6745 
   -0.2500     0.0653 
   -0.1250     0.6860 
    0.0000     1.0000 
    0.1250     0.9360 
    0.2500     0.5653 
    0.3750     0.0755 
    0.5000    -0.3011 
    0.6250    -0.3749 
    0.7500    -0.0706 
    0.8750     0.5440 
    1.0000     1.2837 

function d02uw_example
n   = int64(64);
nip = int64(17);
a = -1;
b =  1;



% Set up solution grid
[x, ifail] = d02uc(n, a, b);

% Set up problem right hand sides for grid
f = x + cos(5*x);

% Solve on equally spaced grid
[xip, fip, ifail] = d02uw(n, nip, x, f);

% Print solution
fprintf('\nNumerical solution F\n');
fprintf('      x          F\n');
for i=1:17
  fprintf('%10.4f %10.4f \n', xip(i), fip(i));
end
 

Numerical solution F
      x          F
   -1.0000    -0.7163 
   -0.8750    -1.2060 
   -0.7500    -1.5706 
   -0.6250    -1.6249 
   -0.5000    -1.3011 
   -0.3750    -0.6745 
   -0.2500     0.0653 
   -0.1250     0.6860 
    0.0000     1.0000 
    0.1250     0.9360 
    0.2500     0.5653 
    0.3750     0.0755 
    0.5000    -0.3011 
    0.6250    -0.3749 
    0.7500    -0.0706 
    0.8750     0.5440 
    1.0000     1.2837 


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–2013