Neville’s method evaluates a polynomial that passes through a given set of and
points for a particular
value using the Newton polynomial form. Neville’s method is similar to a now-defunct procedure named Aitken’s algorithm and is based on the divided differences recursion relation (“Neville’s Algorithm”, n.d).
It was stated before in a previous post on Lagrangian polynomial interpolation that there exists a Lagrange polynomial that passes through points where each is a distinct integer and
at corresponding x values
. The
points
are denoted
.
Neville’s method can be stated as follows:
Let a function be defined at points
where
and
are two distinct members. For each
, there exists a Lagrange polynomial
that interpolates the function
at the
points
. The
th Lagrange polynomial is defined as:
The and
are often denoted
and
, respectively, for ease of notation.
The interpolating polynomials can thus be generated recursively, which we will see in the following example:
Neville’s Method ExampleConsider the following table of and corresponding
values.
x | y |
---|---|
8.1 | 16.9446 |
8.3 | 17.56492 |
8.6 | 18.50515 |
8.7 | 18.82091 |
Suppose we are interested in interpolating a polynomial that passes through these points to approximate the resulting value from an
value of 8.4.
We can construct the interpolating polynomial approximations using the function above:
The approximated values are then used in the next iteration.
Then the final iteration yields the approximated value for the given
value.
Therefore is the approximated value at the point
.
The following function is an implementation of Neville’s method for interpolating and evaluating a polynomial.
poly.neville <- function(x, y, x0) { n <- length(x) q <- matrix(data = 0, n, n) q[,1] <- y for (i in 2:n) { for (j in i:n) { q[j,i] <- ((x0 - x[j-i+1]) * q[j,i-1] - (x0 - x[j]) * q[j-1,i-1]) / (x[j] - x[j-i+1]) } } res <- list('Approximated value'=q[n,n], 'Neville iterations table'=q) return(res)}
Let’s test this function to see if it reports the same result as what we found earlier.
x <- c(8.1, 8.3, 8.6, 8.7)y <- c(16.9446, 17.56492, 18.50515, 18.82091)poly.neville(x, y, 8.4)## $`Approximated value`## [1] 17.87709## ## $`Neville iterations table`## [,1] [,2] [,3] [,4]## [1,] 16.94460 0.00000 0.00000 0.00000## [2,] 17.56492 17.87508 0.00000 0.00000## [3,] 18.50515 17.87833 17.87703 0.00000## [4,] 18.82091 17.87363 17.87716 17.87709
The approximated value is reported as , the same value we calculated previously (minus a few decimal places). The function also outputs the iteration table that stores the intermediate results.
The pracma package contains the neville()
function which also performs Neville’s method of polynomial interpolation and evaluation.
library(pracma)
neville(x, y, 8.4)## [1] 17.87709
The neville()
function reports the same approximated value that we found with our manual calculations and function.
Burden, R. L., & Faires, J. D. (2011). Numerical analysis (9th ed.). Boston, MA: Brooks/Cole, Cengage Learning.
Cheney, E. W., & Kincaid, D. (2013). Numerical mathematics and computing (6th ed.). Boston, MA: Brooks/Cole, Cengage Learning.
Neville’s algorithm. (2016, January 2). In Wikipedia, The Free Encyclopedia. From https://en.wikipedia.org/w/index.php?title=Neville%27s_algorithm&oldid=697870140
The post Neville’s Method of Polynomial Interpolation appeared first on Aaron Schlegel.
var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' }; (function(d, t) {var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;s.src = '//cdn.viglink.com/api/vglnk.js';var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r); }(document, 'script'));R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...