Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

polymul

Multiplying and Dividing Polynomials


Description

Multiply or divide two polynomials given as vectors.

Usage

polymul(p, q)

  polydiv(p, q)

Arguments

p, q

Vectors representing two polynomials.

Details

Polynomial multiplication realized simply by multiplying and summing up all the coefficients. Division is an alias for deconv. Polynomials are defined from highest to lowest coefficient.

Value

Vector representing a polynomial. For division, it returns a list with 'd' the result of the division and 'r' the rest.

Note

conv also realizes polynomial multiplication, through Fast Fourier Transformation, with the drawback that small imaginary parts may evolve. deconv can also be used for polynomial division.

See Also

conv, deconv

Examples

# Multiply x^2 + x + 1 with itself
polymul(c(1, 1, 1), c(0, 1, 1, 1))  #=> 1 2 3 2 1

polydiv(c(1, 2, 3, 2, 1), c(1, 1, 1))
#=> d = c(1,1,1); #=> r = c(0.000000e+00 -1.110223e-16)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.