R: Constructor, coercion, predicate and print functions for...

polynom {PolynomF} | R Documentation

## Constructor, coercion, predicate and print functions for polynom and polylist objects

### Description

The function `polynom` is the constructor function for objects of the eponymous S3 class. `as.polynom` is the standad coercion function to the same class and `is.polynom` tests for inheritance from the class. `polylist` objects are lists of `polynom` objects, again with the eponymous class.

### Usage

    polynom(a = c(0, 1), ..., eps = 0)
    as.polynom(a)
    is.polynom(a)
    polylist(...)
    as.polylist(x)
    is.polylist(x)
    ## S3 method for class 'polynom'
    print(x, variable = "x",
       digits = getOption("digits"), decreasing = FALSE, ...)
    ## S3 method for class 'polylist'
    print(x, ...)

### Arguments

`a` | Numeric coefficient vector for the constructor, specifying the coefficients of the powers from 0 to the maximum, without gaps, in that order, that is, in power series order. For the coercion and predicate functions this may be a coefficient vector, or an existing `polynom` object.
`...` | As yet, unused for `polynom` but may be used in future releases. With `polylist`, objects which are, or may be coerced to, `polynom` objects. With `print` methods, additional agruments either for the generic or for the `print.polynom` method.
`x` | Object which may be coerced to, or tested for, class `polylist`.
`eps` | Absolute tolerance below which components are considered zero.
`variable` | Character string giving name to be used for the independent variable.
`digits` | Integer giving the number of significant digits to use in the printed representation of the coefficients.
`decreasing` | Logical value. Should the powers appear in decreasing order?

### Details

`polynom` objects are represented as `R` functions with the coefficient vector held in an enclosing environment, or closure. They may be used as `R` functions, or as mathematical objects which behave under arithmetic and calculus operatons like polynomials.

Note that polynomials with complex coefficients are not (yet) supported. Nevertheless the root-finding methods described elsewhere will usually give complex zeros.

`polylist` objects are lists of `polynom` objects. Methods are available for dealing with all polynomials on the list simultaneously.

### Value

For `polynom` and `as.polynom`, an `R` function with class `polynom`. For `is.polynom`, a logical value

### Author(s)

Bill Venables

### References

None

### Examples

    x <- polynom()  # polynomial 'x'
    p <- (x-1)^2 + 10*x^3 + 5*x^4
    p
    # 1 - 2*x + x^2 + 10*x^3 + 5*x^4

    plot(polylist(p, deriv(p), integral(p)),
        xlim = c(-2, 1), ylim = c(-10, 10))
    abline(h=0, lty = "dashed", col = "grey")

    print(p, variable = "z", decreasing = TRUE)

[Package PolynomF version 1.0-1 Index]