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.
make_indeterminate_list(vars) mp(string, varorder, stars_only = FALSE)
vars | a character vector of indeterminates |
---|---|
string | a character string containing a polynomial, see examples |
varorder | (optional) order of variables in string |
stars_only | if you format your multiplications using asterisks, setting
this to |
An object of class mpoly.
( m <- mp("x + y + x y") )#> x + y + x yis.mpoly( m )#> [1] TRUEunclass(m)#> [[1]] #> x coef #> 1 1 #> #> [[2]] #> y coef #> 1 1 #> #> [[3]] #> x y coef #> 1 1 1 #>mp("x + 2 y + x^2 y + x y z")#> x + 2 y + x^2 y + x y z#> x + 2 y + y x^2 + y z x#> x + y #> 2 xis.mpolyList(ms)#> [1] TRUE#> 2 x y + y z + 1 #> x^2 + x z + 2 #> x y#> 10 x^9 + 90 x^8 y + 360 x^7 y^2 + 840 x^6 y^3 + 1260 x^5 y^4 + 1260 x^4 y^5 + 840 x^3 y^6 + 360 x^2 y^7 + 90 x y^8 + 10 y^9 #> 10 x^9 + 90 x^8 y + 360 x^7 y^2 + 840 x^6 y^3 + 1260 x^5 y^4 + 1260 x^4 y^5 + 840 x^3 y^6 + 360 x^2 y^7 + 90 x y^8 + 10 y^9#> x + y #> x - y#> [1] "x + y" "x - y"mp(strings)#> x + y #> x - y