[ top | up ]

Construct a Character String from a Polynomial

Usage

make.character(p, variable = "x", style = c("ordinary", "horner"))

Arguments

p An object of class polynomial
variable Name for the independent variable to be used in the character string
style Indicator to prescribe either truncated power series (ordinary) or recursive expansion (horner) form.

Description

Essentially a coercion method function from objects of class polynomial to a character string, but with slightly more flexibility than is possible with a method under the system as.character generic.

Used mainly in as.function.polynomial, but may be useful in other contexts.

Value

An object of mode character.

See Also

as.function.polynomial

Examples

pr <- 
pr
-120 + 274*x - 225*x^2 + 85*x^3 - 15*x^4 + x^5 
make.character(pr, variable=y, style="o")
## [1] "-120 + 274*y - 225*y^2 + 85*y^3 - 15*y^4 + y^5"
make.character(pr, variable="z", style="h")
## [1] "-120 + z * (274 + z * (-225 + z * (85 + z * (-15 + z * (1)))))"