Learn R Programming

PolynomF (version 2.0-8)

poly_calc: Lagrange interpolation polynomial

Description

Calculate the Lagrange interpolation polynomial, or list of polynomials, given a set of (x, y) points to fit

Usage

poly_calc(x, y, tol = sqrt(.Machine$double.eps), lab = dimnames(y)[[2]])

poly_from_zeros(...)

poly_from_roots(...)

poly_from_roots(...)

poly_from_values(x, y, tol = sqrt(.Machine$double.eps), lab = dimnames(y)[[2]])

Value

An interpolation polynomial, or list of interpolating polynomials.

Arguments

x

A numeric vector of x-points at which the y-values are specified.

y

Either a numeric vector of the same length as x or a numeric matrix with rows matching the length of x. If y is missing (not specified) then a polynomial with zero at x is returned.

tol

A numeric tolerance for duplicated x values.

lab

A character string vector of names for the list result when y is a matrix.

...

A list of specified zeros (for subsidiary functions)

Examples

Run this code
(p <- poly_calc(0:5)) ## same as poly_from_zeros(0:5)
(p <- poly_calc(0:5, exp(0:5)))
plot(p)
curve(exp, add = TRUE, col = "red")

Run the code above in your browser using DataLab