Skip to contents

Substitute a coefficient of a polynomial with a*x + b. For a polynomial with a coefficient vector \(poly(x; coeff)\), compute the coefficient vector of $$poly(a*x + b; coeff).$$

Usage

polyaxb(coeff, c, a, b)

Arguments

coeff

A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and the last element is the largest degree of coefficients.

c

A multiple factor of constant to be applied to all coefficients.

a

A coefficient of 1st degree of a*x + b.

b

A coefficient of 0th degree of a*x + b.

Value

A substituted coefficient.

See also

Examples

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
#> [1]  8.881784e-16 -8.881784e-16  0.000000e+00