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 + 1$n+1$ function values, f(xi)$f\left({x}_{\mathit{i}}\right)$, on a supplied grid, xi${x}_{\mathit{i}}$, for i = 0,1,,n$\mathit{i}=0,1,\dots ,n$, onto a set of m$m$ values, (j)$\stackrel{^}{f}\left({\stackrel{^}{x}}_{\mathit{j}}\right)$, on a uniform grid, j${\stackrel{^}{x}}_{\mathit{j}}$, for j = 1,2,,m$\mathit{j}=1,2,\dots ,m$. The image $\stackrel{^}{x}$ has the same range as x$x$, so that j = xmin + ((j1) / (m1)) × (xmaxxmin) ${\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 j = 1,2,,m$\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 (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$n$, where the number of grid points for the input data is n + 1$n+1$.
Constraint: n > 0${\mathbf{n}}>0$ and n is even.
2:     nip – int64int32nag_int scalar
The number, m$m$, of grid points in the uniform mesh $\stackrel{^}{x}$ onto which function values are interpolated. If nip = 1${\mathbf{nip}}=1$ then on successful exit from nag_ode_bvp_ps_lin_grid_vals (d02uw), fip(1)${\mathbf{fip}}\left(1\right)$ will contain the value f(xn)$f\left({x}_{n}\right)$.
Constraint: nip > 0${\mathbf{nip}}>0$.
3:     x(n + 1${\mathbf{n}}+1$) – double array
The grid points, xi${x}_{\mathit{i}}$, for i = 0,1,,n$\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 (d02uc).
4:     f(n + 1${\mathbf{n}}+1$) – double array
The function values, f(xi)$f\left({x}_{\mathit{i}}\right)$, for i = 0,1,,n$\mathit{i}=0,1,\dots ,n$.

None.

None.

### Output Parameters

1:     xip(nip) – double array
The evenly-spaced grid points, j${\stackrel{^}{x}}_{\mathit{j}}$, for j = 1,2,,m$\mathit{j}=1,2,\dots ,m$.
2:     fip(nip) – double array
The set of interpolated values (j)$\stackrel{^}{f}\left({\stackrel{^}{x}}_{\mathit{j}}\right)$, for j = 1,2,,m$\mathit{j}=1,2,\dots ,m$. Here (j)f(x = j)$\stackrel{^}{f}\left({\stackrel{^}{x}}_{\mathit{j}}\right)\approx f\left(x={\stackrel{^}{x}}_{\mathit{j}}\right)$.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

ifail = 1${\mathbf{ifail}}=1$
Constraint: n > 0${\mathbf{n}}>0$.
Constraint: n is even.
ifail = 2${\mathbf{ifail}}=2$
Constraint: nip > 0${\mathbf{nip}}>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.

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