Swap polynomial indeterminates

swap(p, variable, replacement)

Arguments

p

polynomial

variable

the variable in the polynomial to replace

replacement

the replacement variable

Value

a mpoly object

Examples

(p <- mp("(x + y)^2"))
#> x^2 + 2 x y + y^2
swap(p, "x", "t")
#> t^2 + 2 t y + y^2
## the meta data is retained (p <- bernstein(3, 5))
#> 10 x^3 - 20 x^4 + 10 x^5
(p2 <- swap(p, "x", "t"))
#> 10 t^3 - 20 t^4 + 10 t^5
#> [1] TRUE
(p <- chebyshev(3))
#> -3 x + 4 x^3
(p2 <- swap(p, "x", "t"))
#> -3 t + 4 t^3
#> [1] TRUE