R: Functions to generate polynomials in several standard ways

poly.calc {PolynomF} | R Documentation

## Functions to generate polynomials in several standard ways

### Description

`poly.calc` (alias `poly.from.values`) computes the Lagrange interpolating polynomial. `poly.from.zeros` (alias `poly.from.roots`) computes the monic polynomial with specified zeros. `poly.orth` calculates polynomials orthogonal over a discrete set of $x-$values, as done numerically by the standard `R` function `poly`.

### Usage

    poly.calc(x, y, tol = sqrt(.Machine$double.eps), lab = dimnames(y)[[2]])
    poly.from.values(x, y, tol = sqrt(.Machine$double.eps), lab = dimnames(y)[[2]])
    poly.from.zeros(...)
    poly.from.roots(...)
    poly.orth(x, degree = length(unique(x)) - 1, norm = TRUE)

### Arguments

`x` | A numeric vector of values for the polynomial variable.
`y` | A numeric vector or matrix specifying values for the polynomial.
`tol` | A numeric tolerance
`lab` | A character vector providing names for the `polylist` of polynomials.
`degree` | The maximum degree for the orthogonal polynomials required.
`norm` | Logical value. Should the polynomials be normalised to be of length 1?)
`...` | Not presently used.

### Details

Given a vector of distinct values `x` and a vector `y` of the same length, `poly.calc` computes the Lagranging intrepolating polynomial they define. If `y` is a matrix, its row size must match the length of `x` and interpolating polynomials are computed for all columns. In this case the value is a `polylist` object.

`poly.from.values` is a complete alias for `poly.calc`.

The function `poly.from.zeros` computes the monic polynomial with zeros as given by the arguments. The zeros may be specified either as separate artuments or as a single numeric vector.

`poly.from.roots` is a complete alias for `poly.from.zeros`.

`poly.orth` calculates polynomials orthogonal with respect to the uniform measure over a discrete set of $x-$values given by the artument `x`. These are the polynomials for which the standard function `poly` can be used to compute numerical values.

### Value

A `polynom` object, or, in the case of `poly.calc` and `poly.orth`, possibly a `polylist` object

### Author(s)

Bill Venables

### References

None

### See Also

`poly`

### Examples

    x <- polynom()
    H <- polylist(1, x)
    for(j in 2:10)
      H[[j+1]] <- x*H[[j]] - (j-1)*H[[j-1]]
    Hf <- as.function(H)
    x0 <- -5:5
    y0 <- Hf(x0)
    J <- poly.from.values(x0, y0)
    all.equal(H[[11]], J[[11]])

    p1 <- poly.from.zeros(-3:2)
    p2 <- poly.from.zeros(0:4)
    p3 <- GCD(p1, p2)
    p4 <- LCM(p1, p2)

    solve(polylist(p1, p2, p3, p4))

    po <- poly.orth(-4:4, degree = 4)
    plot(po)

    round(crossprod(as.function(po)(-4:4)), 10)

[Package PolynomF version 1.0-1 Index]