Learn R Programming

mpoly (version 1.1.2)

components: Polynomial components

Description

Compute quantities/expressions related to a multivariate polynomial.

Usage

# S3 method for mpoly
[(x, ndx)

LT(x, varorder = vars(x), order = "lex")

LC(x, varorder = vars(x), order = "lex")

LM(x, varorder = vars(x), order = "lex")

multideg(x, varorder = vars(x), order = "lex")

totaldeg(x)

monomials(x, unit = FALSE)

exponents(x, reduced = FALSE)

# S3 method for mpoly coef(object, ...)

normalize_coefficients(p, norm = function(x) sqrt(sum(x^2)))

coef_lift(p)

Value

An object of class mpoly or mpolyList, depending on the context

Arguments

x

an object of class mpoly

ndx

a subsetting index

varorder

the order of the variables

order

a total order used to order the terms

unit

for monomials(), should the monomials have coefficient 1?

reduced

if TRUE, don't include zero degrees

object

mpoly object to pass to coef()

...

In coef(), additional arguments passed to print.mpoly() for the names of the resulting vector

p

an object of class mpoly or mpolyList

norm

a norm (function) to normalize the coefficients of a polynomial, defaults to the Euclidean norm

Examples

Run this code
(p <- mp("x y^2 + x (x+1) (x+2) x z + 3 x^10"))
p[2]
p[-2]
p[2:3]

LT(p)
LC(p)
LM(p)

multideg(p)
totaldeg(p)
monomials(p)
monomials(p, unit = TRUE)
coef(p)

p[1:2]
coef_lift(p[1:2])

exponents(p)
exponents(p, reduce = TRUE)
lapply(exponents(p), is.integer)

homogeneous_components(p)

(p <- mp("(x + y)^2"))
normalize_coefficients(p)
norm <- function(v) sqrt(sum(v^2))
norm(coef( normalize_coefficients(p) ))

abs_norm <- function(x) sum(abs(x))
normalize_coefficients(p, norm = abs_norm)

p <- mp(c("x", "2 y"))
normalize_coefficients(p)

# normalize_coefficients on the zero polynomial returns the zero polynomial
normalize_coefficients(mp("0"))


Run the code above in your browser using DataLab