set.seed(123)
x <- 1:5
y <- rnorm(x)
xout <- 0.5 + 1:4
p1 <- neville(x, y)
plot(p1, xlim = range(x), ylim = extendrange(y, f = 1), panel.first = grid())
points(x, y, col = 4)
points(xout, lagrange(x, y, xout), col = 2)
Run the code above in your browser using DataLab