Accelerating the pace of engineering and science

# fnxtr

Extrapolate function

## Syntax

g = fnxtr(f,order)
fnxtr(f)

## Description

g = fnxtr(f,order) returns the spline (in ppform) that agrees with the spline in f on the latter's basic interval but is a polynomial of the given order outside it, with 2 the default for order, in such a way that the spline in g satisfies at least order smoothness conditions at the ends of f's basic interval, i.e., at the new breaks.

f must be in B-form, BBform, or ppform.

While order can be any nonnegative integer, fnxtr is useful mainly when order is positive but less than the order of f.

If order is zero, then g describes the same spline as fn2fm(f,'B-) but is in ppform and has a larger basic interval.

If order is at least as big as f's order, then g describes the same pp as fn2fm(f,'pp') but uses two more pieces and has a larger basic interval.

If f is m-variate, then order may be an m-vector, in which case order(i) specifies the matching order to be used in the i-th variable, i = 1:m.

If order<0, then g is exactly the same as fn2fm(f,'pp'). This unusual option is useful when, in the multivariate case, extrapolation is to take place in only some but not all variables.

fnxtr(f) is the same as fnxtr(f,2).

## Examples

Example 1. The cubic smoothing spline for given data x,y is, like any other `natural' cubic spline, required to have zero second derivative outside the interval spanned by the data sites. Hence, if such a spline is to be evaluated outside that interval, it should be constructed as s = fnxtr(csaps(x,y)). A Cubic Smoothing Spline Properly Extrapolated, generated by the following code, shows the difference.

```rng(6); x = rand(1,21); s = csaps(x,x.^3); sn = fnxtr(s);
fnplt(s,[-.5 1.4],3), hold on, fnplt(sn,[-.5 1.4],.5,'r',2)
legend('cubic smoothing spline','... properly extrapolated')
hold off
```

A Cubic Smoothing Spline Properly Extrapolated

Example 2. Here is the plot of a bivariate B-spline, quadratically extrapolated in the first variable and not at all extrapolated in the second, as generated by

```fnplt(fnxtr(spmak({0:3,0:4},1),[3,-1]))
```

A Bivariate B-spline Quadratically Extrapolated In One Direction