Homogenize a polynomial.

homogenize(x, indeterminate = "t")

dehomogenize(x, indeterminate = "t")

is.homogeneous(x)

homogeneous_components(x)

Arguments

x

an mpoly object, see mpoly()

indeterminate

name of homogenization

Value

a (de/homogenized) mpoly or an mpolyList

Examples

x <- mp("x^4 + y + 2 x y^2 - 3 z") is.homogeneous(x)
#> [1] FALSE
(xh <- homogenize(x))
#> x^4 + y t^3 + 2 x y^2 t - 3 z t^3
is.homogeneous(xh)
#> [1] TRUE
homogeneous_components(x)
#> y - 3 z #> 2 y^2 x #> x^4
homogenize(x, "o")
#> x^4 + y o^3 + 2 x y^2 o - 3 z o^3
xh <- homogenize(x) dehomogenize(xh) # assumes indeterminate = "t"
#> x^4 + y + 2 x y^2 - 3 z
plug(xh, "t", 1) # same effect, but dehomogenize is faster
#> x^4 + y + 2 x y^2 - 3 z
# the functions are vectorized (ps <- mp(c("x + y^2", "x + y^3")))
#> x + y^2 #> x + y^3
(psh <- homogenize(ps))
#> x t + y^2 #> x t^2 + y^3
dehomogenize(psh)
#> x + y^2 #> x + y^3
# demonstrating a leading property of homogeneous polynomials library(magrittr)
#> #> Attaching package: ‘magrittr’
#> The following object is masked from ‘package:tidyr’: #> #> extract
p <- mp("x^2 + 2 x + 3") (ph <- homogenize(p, "y"))
#> x^2 + 2 x y + 3 y^2
lambda <- 3 (d <- totaldeg(p))
#> [1] 2
ph %>% plug("x", lambda*mp("x")) %>% plug("y", lambda*mp("y"))
#> 9 x^2 + 18 x y + 27 y^2
lambda^d * ph
#> 9 x^2 + 18 x y + 27 y^2