coeff <- c(2, -2, 1)
a <- 1.1
b <- 1.2
coeff1 <- c(b, a)
coeff2 <- polyaxb(coeff, 1, a, b)
xv <- c(1, 2, 3)
## a*x + b
yv1 <- eval_poly(coeff1, xv)
## polynomial(a*x + b, coeff)
yv2 <- eval_poly(coeff, yv1)
## polynomial(x, coeff2)
yv <- eval_poly(coeff2, xv)
## This value is nearly 0 in the presence of rounding errors
yv - yv2
Run the code above in your browser using DataLab