as.function.qspray {qspray}R Documentation

Multivariate polynomial as function

Description

Coerces a qspray polynomial into a function.

Usage

## S3 method for class 'qspray'
as.function(x, N = FALSE, ...)

Arguments

x

object of class qspray

N

Boolean, whether the function must numerically approximate the result

...

ignored

Value

A function having the same variables as the polynomial. If N=FALSE, it returns a string. If N=TRUE, it returns a number if the result does not contain any variable, otherwise it returns a R expression.

Examples

library(qspray)
P <- (qlone(1) + "1/2"*qlone(2))^2 + 5
f <- as.function(P)
g <- as.function(P, N = TRUE)
f(2, "3/7")
g(2, "3/7")
f("x", "y")
g("x", "y")
# the evaluation is performed by (R)yacas and complex numbers are
# allowed; the imaginary unit is denoted by `I`
f("2 + 2*I", "Sqrt(2)")
g("2 + 2*I", "Sqrt(2)")

[Package qspray version 3.1.0 Index]