Learn R Programming

pracma (version 1.1.6)

ratinterp: Rational Interpolation

Description

Burlisch-Stoer rational interpolation.

Usage

ratinterp(x, y, xs = x)

Arguments

x
numeric vector; points on the x-axis; needs to be sorted; at least three points required.
y
numeric vector; values of the assumed underlying function; x and y must be of the same length.
xs
numeric vector; points at which to compute the interpolation; all points must lie between min(x) and max(x).

Value

  • Numeric vector representing values at points xs.

Details

The Burlisch-Stoer approach to rational interpolation is a recursive procedure (similar to the Newton form of polynomial interpolation) that produces a ``diagonal'' rational function, that is the degree of the numerator is either the same or one less than the degree of the denominator.

Polynomial interpolation will have difficulties if some kind of singularity exists in the neighborhood, even if the pole occurs in the complex plane. For instance, Runge's function has a pole at $z = 0.2 i$, quite close to the interval $[-1, 1]$.

References

Stoer, J., and R. Bulirsch (2002). Introduction to Numerical Analysis. Third Edition, Springer-Verlag, New York.

Fausett, L. V. (2008). Applied Numerical Analysis Using Matlab. Second Edition, Pearson Education.

See Also

rationalfit, pade

Examples

Run this code
## Rational interpolation of Runge's function
x <- c(-1, -0.5, 0, 0.5, 1.0)
y <- runge(x)
xs <- linspace(-1, 1)
ys <- runge(xs)
yy <- ratinterp(x, y, xs)  # returns exactly the Runge function

plot(xs, ys, type="l", col="blue", lty = 2, lwd = 3)
points(x, y)
yy <- ratinterp(x, y, xs)
lines(xs, yy, col="red")
grid()

Run the code above in your browser using DataLab