Last data update: 2014.03.03

R: Define a multivariate polynomial.
mpR Documentation

Define a multivariate polynomial.

Description

mp is a smart function which attempts to create a formal mpoly object from a character string containing the usual representation of a multivariate polynomial.

Usage

mp(string, varorder)

Arguments

string

a character string containing a polynomial, see examples

varorder

(optional) order of variables in string

Value

An object of class mpoly.

Author(s)

David Kahle david.kahle@gmail.com

See Also

mpoly

Examples

( m <- mp("x + y + x y") )
is.mpoly( m )
unclass(m)


mp("x + 2 y + x^2 y + x y z") 
mp("x + 2 y + x^2 y + x y z", varorder = c("y", "z", "x")) 
# mp("x + 2 y + x^2 y", varorder = c("q", "p")) # -> error

( ms <- mp(c("x + y", "2 x")) )
is.mpolyList(ms)


gradient( mp("x + 2 y + x^2 y + x y z") ) 
gradient( mp("(x + y)^10") ) 

# mp and the print methods are kinds of inverses of each other
( polys <- mp(c("x + y", "x - y")) )
strings <- print(polys)
strings
mp(strings)








Results