R: Constructor, coercion, predicate and print functions for...
polynom
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
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(PolynomF)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/PolynomF/polynom.Rd_%03d_medium.png", width=480, height=480)
> ### Name: polynom
> ### Title: Constructor, coercion, predicate and print functions for polynom
> ### and polylist objects
> ### Aliases: polynom as.polynom is.polynom polylist as.polylist is.polylist
> ### print.polynom print.polylist
> ### Keywords: symbolmath
>
> ### ** 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
> # 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)
5*z^4 + 10*z^3 + z^2 - 2*z + 1
>
>
>
>
>
>
> dev.off()
null device
1
>