Add two polynomials given as vectors.

polyadd(p, q)

Arguments

p, q

Vectors representing two polynomials.

Details

Polynomial addition realized simply by multiplying and summing up all the coefficients after extending vectors to the same length.

Value

Vector representing a polynomial.

Note

There is no such function in Matlab or Octave.

See also

Examples

polyadd(c(1, 1, 1), 1)
#> [1] 1 1 2
polyadd(c(1, 1, 1), c(0, 0, 1))
#> [1] 1 1 2
polyadd(c(-0.5, 1, -1), c(0.5, 0, 1))
#> [1] 1 0