Learn R Programming

PolynomF (version 2.0-8)

polynom: Polynomial construction

Description

Functions to construct polynomial objects and check class membership

Usage

polynom(a = c(0, 1), ..., eps = 0)

polynomial(a = c(0, 1), ..., eps = 0)

as_polynom(a)

is_polynom(a)

polylist(...)

is_polylist(x)

as_polylist(x)

Value

A polynomial object.

Arguments

a

A polynom object, or a numeric vector of coefficients (in "power series" order) or a vector object which can be coerced to one.

...

Additional arguments, currently ignored.

eps

A small non-negative tolerance to check for zero components.

x

An object of class "polylist", at least potentially.

Examples

Run this code
(s <- polynomial())
(p <- polynomial(c(1, 5, 4, 1)/11))
oldPar <- par(mar = c(5,5,2,2)+0.1)
plot(p, xlim = 0:1, ylim = 0:1, type = "n", bty="n",
     xlab = "s", ylab = expression({P^(n)}(s)))
lines(s, limits = 0:1)
P <- p
for(j in 1:7) {
  lines(P, col = j+1, limits = 0:1)
  P <- p(P)
}
lines(P, limits = 0:1, col = 9)
(r <- Re(solve((p-s)/(1-s))))
arrows(r, p(r), r, par("usr")[3], lwd = 0.5,
       length = 0.125, angle = 15)
text(r, 0.025, paste("r =", format(r, digits = 3)))
leg <- sapply(0:8, function(x) bquote({P^(.(x))}(s)))
legend("topleft", legend = as.expression(leg),
       lty = "solid", col = 1:9, bty = "n", ncol=3)
par(oldPar)
rm(leg, oldPar, p, P, r, s, j)

Run the code above in your browser using DataLab