Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

as.function.polynom

Coercion to function


Description

PolynomF objects ARE functions, but this coercion method creates from a polynomial object a pure function with the coefficients fully exposed in the code and which evaluates the polynomial more efficiently.

Usage

## S3 method for class 'polynom'
as.function(x, variable = "x", ...)

## S3 method for class 'polylist'
as.function(x, ...)

Arguments

x

A polynomial object

variable

Character string: what variable name should be used?

...

Additional arguments

Value

An explicit R function evaluating the polynomial

Examples

p <- poly_from_zeros(-2:3)
p
as.function(p)

PolynomF

Polynomials in R

v2.0-3
GPL-2
Authors
Bill Venables, with contribution by Kurt Hornik and Georgi Boshnakov
Initial release
2020-02-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.