newtonInterp: Lagrange and Newtons Interpolation

View source: R/neville.R

newtonInterpR Documentation

Lagrange and Newtons Interpolation

Description

Lagrange's and Newton's method of polynomial interpolation.

Usage

newtonInterp(x, y, xs = c())

lagrangeInterp(x, y, xs)

Arguments

x, y

x-, y-coordinates of data points defining the polynomial.

xs

either empty, or a vector of points to be interpolated.

Details

Straightforward implementation of Lagrange's Newton's method (vectorized in xs).

Value

A vector of values at xs of the polynomial defined by x,y.

References

Each textbook on numerical analysis.

See Also

neville, barylag

Examples

p <- Poly(c(1, 2, 3))
fp <- function(x) polyval(p, x)

x <- 0:4; y <- fp(x)
xx <- linspace(0, 4, 51)
yy <- lagrangeInterp(x, y, xx)
yy <- newtonInterp(x, y, xx)
## Not run: 
ezplot(fp, 0, 4)
points(xx, yy)
## End(Not run)

pracma documentation built on Nov. 10, 2023, 1:14 a.m.