NAG Library Routine Document

d02uwf (bvp_ps_lin_grid_vals)

1
Purpose

d02uwf 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. d02uwf is primarily a utility routine to map a set of function values specified on a Chebyshev Gauss–Lobatto grid onto a uniform grid.

2
Specification

Fortran Interface
Subroutine d02uwf ( n, nip, x, f, xip, fip, ifail)
Integer, Intent (In):: n, nip
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: x(n+1), f(n+1)
Real (Kind=nag_wp), Intent (Out):: xip(nip), fip(nip)
C Header Interface
#include <nagmk26.h>
void  d02uwf_ (const Integer *n, const Integer *nip, const double x[], const double f[], double xip[], double fip[], Integer *ifail)

3
Description

d02uwf 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).
d02uwf is primarily a utility routine to map a set of function values specified on a Chebyshev Gauss–Lobatto grid computed by d02ucf onto an evenly-spaced grid with the same range as the original grid.

4
References

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

5
Arguments

1:     n – IntegerInput
On entry: n, where the number of grid points for the input data is n+1.
Constraint: n>0 and n is even.
2:     nip – IntegerInput
On entry: 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 d02uwf, fip1 will contain the value fxn.
Constraint: nip>0.
3:     xn+1 – Real (Kind=nag_wp) arrayInput
On entry: 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 d02ucf.
4:     fn+1 – Real (Kind=nag_wp) arrayInput
On entry: the function values, fxi, for i=0,1,,n.
5:     xipnip – Real (Kind=nag_wp) arrayOutput
On exit: the evenly-spaced grid points, x^j, for j=1,2,,m.
6:     fipnip – Real (Kind=nag_wp) arrayOutput
On exit: the set of interpolated values f^x^j, for j=1,2,,m. Here f^x^jfx=x^j.
7:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, n=value.
Constraint: n>0.
On entry, n=value.
Constraint: n is even.
ifail=2
On entry, nip=value.
Constraint: nip>0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

d02uwf 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.

8
Parallelism and Performance

d02uwf is not threaded in any implementation.

9
Further Comments

None.

10
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.

10.1
Program Text

Program Text (d02uwfe.f90)

10.2
Program Data

Program Data (d02uwfe.d)

10.3
Program Results

Program Results (d02uwfe.r)