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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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+1 function values, fxi, on a supplied grid, xi, for i=0,1,,n, onto a set of m values, f^x^j, on a uniform grid, x^j, for j=1,2,,m. The image x^ has the same range as x, so that x^j = xmin + j-1 / m-1 × xmax - xmin , for j=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
n, where the number of grid points for the input data is n+1.
Constraint: n>0 and n is even.
2:     nip int64int32nag_int scalar
The number, m, of grid points in the uniform mesh x^ onto which function values are interpolated. If nip=1 then on successful exit from nag_ode_bvp_ps_lin_grid_vals (d02uw), fip1 will contain the value fxn.
Constraint: nip>0.
3:     xn+1 – double array
The grid points, xi, for i=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:     fn+1 – double array
The function values, fxi, for i=0,1,,n.

Optional Input Parameters

None.

Output Parameters

1:     xipnip – double array
The evenly-spaced grid points, x^j, for j=1,2,,m.
2:     fipnip – double array
The set of interpolated values f^x^j, for j=1,2,,m. Here f^x^jfx=x^j.
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
Constraint: n>0.
Constraint: n is even.
   ifail=2
Constraint: nip>0.
   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

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

This example interpolates the function x+cos5x, as specified on a 65-point Gauss–Lobatto grid on -1,1, onto a coarse uniform grid.
function d02uw_example


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

n   = int64(64);
a = -1;
b =  1;

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

% Set up function on grid
f = x + cos(5*x);

% Interpolate onto smaller equally spaced grid
nip = int64(17);
[xip, fip, ifail] = d02uw(n, nip, x, f);

% Display interpolated values
fprintf('\nInterpolated function values\n');
fprintf('      x          F\n');
fprintf('%10.4f %10.4f \n', [xip fip]');


d02uw example results


Interpolated function values
      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–2015