View source: R/nevilles_algorithm.R
neville | R Documentation |
Compute the Lagrange Interpolation Polynomial from a given set of x- and y-values, or, alterntively, compute the interpolated values at a set of given x-values. Two algorithms are provided, namely Neville's algorithm, or a more direct version based on the usual Lagrange formula. The latter is generally faster but the former can be more accurate numerically.
neville(x, y, x0 = polynomial()) lagrange(x, y, x0 = polynomial())
x |
A numeric vector of x-values |
y |
A numeric values of y-values corresponding to the x-values |
x0 |
Either a polynomial object or a vector of x-values for which interpolated y-values are required. |
Either an interpolation polynomial object or a vector of interpolated y-values
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.