nag_ode_bvp_ps_lin_grid_vals (d02uwc) (PDF version)
d02 Chapter Contents
d02 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_ode_bvp_ps_lin_grid_vals (d02uwc)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_ode_bvp_ps_lin_grid_vals (Integer n, Integer nip, const double x[], const double f[], double xip[], double fip[], NagError *fail)

## 3  Description

nag_ode_bvp_ps_lin_grid_vals (d02uwc) 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).
nag_ode_bvp_ps_lin_grid_vals (d02uwc) 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 (d02ucc) onto an evenly-spaced grid with the same range as the original grid.
Berrut J P and Trefethen L N (2004) Barycentric lagrange interpolation SIAM Rev. 46(3) 501–517

## 5  Arguments

1:     nIntegerInput
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:     nipIntegerInput
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 nag_ode_bvp_ps_lin_grid_vals (d02uwc), ${\mathbf{fip}}\left[0\right]$ will contain the value $f\left({x}_{n}\right)$.
Constraint: ${\mathbf{nip}}>0$.
3:     x[${\mathbf{n}}+1$]const doubleInput
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 nag_ode_bvp_ps_lin_cgl_grid (d02ucc).
4:     f[${\mathbf{n}}+1$]const doubleInput
On entry: the function values, $f\left({x}_{\mathit{i}}\right)$, for $\mathit{i}=0,1,\dots ,n$.
5:     xip[nip]doubleOutput
On exit: the evenly-spaced grid points, ${\stackrel{^}{x}}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,m$.
6:     fip[nip]doubleOutput
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:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_BAD_PARAM
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}>0$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: n is even.
On entry, ${\mathbf{nip}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nip}}>0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.

## 7  Accuracy

nag_ode_bvp_ps_lin_grid_vals (d02uwc) 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.

Not applicable.

None.

## 10  Example

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.1  Program Text

Program Text (d02uwce.c)

### 10.2  Program Data

Program Data (d02uwce.d)

### 10.3  Program Results

Program Results (d02uwce.r)

nag_ode_bvp_ps_lin_grid_vals (d02uwc) (PDF version)
d02 Chapter Contents
d02 Chapter Introduction
NAG Library Manual