# NAG FL Interfaced02uwf (bvp_​ps_​lin_​grid_​vals)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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.

## 2Specification

Fortran Interface
 Subroutine d02uwf ( n, nip, x, f, xip, fip,
 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)
#include <nag.h>
 void d02uwf_ (const Integer *n, const Integer *nip, const double x[], const double f[], double xip[], double fip[], Integer *ifail)
The routine may be called by the names d02uwf or nagf_ode_bvp_ps_lin_grid_vals.

## 3Description

d02uwf interpolates from a set of $n+1$ function values, $f\left({x}_{\mathit{i}}\right)$, on a supplied grid, ${x}_{\mathit{i}}$, for $\mathit{i}=0,1,\dots ,n$, onto a set of $m$ values, $\stackrel{^}{f}\left({\stackrel{^}{x}}_{\mathit{j}}\right)$, on a uniform grid, ${\stackrel{^}{x}}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,m$. The image $\stackrel{^}{x}$ has the same range as $x$, so that ${\stackrel{^}{x}}_{\mathit{j}}={x}_{\mathrm{min}}+\left(\left(\mathit{j}-1\right)/\left(m-1\right)\right)×\left({x}_{\mathrm{max}}-{x}_{\mathrm{min}}\right)$, for $\mathit{j}=1,2,\dots ,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.

## 4References

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

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, where the number of grid points for the input data is $n+1$.
Constraint: ${\mathbf{n}}>0$ and n is even.
2: $\mathbf{nip}$Integer Input
On entry: the number, $m$, of grid points in the uniform mesh $\stackrel{^}{x}$ onto which function values are interpolated. If ${\mathbf{nip}}=1$ then on successful exit from d02uwf, ${\mathbf{fip}}\left(1\right)$ will contain the value $f\left({x}_{n}\right)$.
Constraint: ${\mathbf{nip}}>0$.
3: $\mathbf{x}\left({\mathbf{n}}+1\right)$Real (Kind=nag_wp) array Input
On entry: the grid points, ${x}_{\mathit{i}}$, for $\mathit{i}=0,1,\dots ,n$, at which the function is specified.
Usually this should be the array of Chebyshev Gauss–Lobatto points returned in d02ucf.
4: $\mathbf{f}\left({\mathbf{n}}+1\right)$Real (Kind=nag_wp) array Input
On entry: the function values, $f\left({x}_{\mathit{i}}\right)$, for $\mathit{i}=0,1,\dots ,n$.
5: $\mathbf{xip}\left({\mathbf{nip}}\right)$Real (Kind=nag_wp) array Output
On exit: the evenly-spaced grid points, ${\stackrel{^}{x}}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,m$.
6: $\mathbf{fip}\left({\mathbf{nip}}\right)$Real (Kind=nag_wp) array Output
On exit: the set of interpolated values $\stackrel{^}{f}\left({\stackrel{^}{x}}_{\mathit{j}}\right)$, for $\mathit{j}=1,2,\dots ,m$. Here $\stackrel{^}{f}\left({\stackrel{^}{x}}_{\mathit{j}}\right)\approx f\left(x={\stackrel{^}{x}}_{\mathit{j}}\right)$.
7: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}>0$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: n is even.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{nip}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nip}}>0$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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.

## 8Parallelism and Performance

d02uwf is not threaded in any implementation.

None.

## 10Example

This example interpolates the function $x+\mathrm{cos}\left(5x\right)$, as specified on a $65$-point Gauss–Lobatto grid on $\left[-1,1\right]$, onto a coarse uniform grid.

### 10.1Program Text

Program Text (d02uwfe.f90)

### 10.2Program Data

Program Data (d02uwfe.d)

### 10.3Program Results

Program Results (d02uwfe.r)