ratinterp(x, y, xs = x)
x
and y
must be of the same length.min(x)
and max(x)
.xs
.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]$.
Fausett, L. V. (2008). Applied Numerical Analysis Using Matlab. Second Edition, Pearson Education.
rationalfit
, pade
## 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