polymult#

Purpose#

Multiplies polynomials.

Format#

c = polymult(c1, c2)#
Parameters:
  • c1 ((D1+1)x1 vector) – coefficients of the first polynomial

  • c2 ((D2+1)x1 vector) – coefficients of the second polynomial

Returns:

c ((D1+D2)x1 vector) – contains the coefficients of the product of the two polynomials.

Examples#

This example multiplies the polynomials:

\[(2x + 1)(2x^2 + 1)\]

and returns the answer:

\[4x^3 + 2x^2 + 2x + 1\]
// Assign c1 to represent 2x + 1
c1 = { 2, 1 };

// Assign c2 to represent 2x2 + 1
c2 = { 2, 0, 1 };

c = polymult(c1, c2);

After the code above:

    4
c = 2
    2
    1

Technical Notes#

If the degree of c1 is D1 (e.g., if D1=3, then the polynomial corresponding to c1 is cubic), then there must be D1+1 elements in c1 (e.g., 4 elements for a cubic). Thus, for instance the coefficients for the polynomial

\[5x^3 + 6x + 3\]

would be:

// Using the pipe operator for vertical concatenation
c1 = 5|0|6|3;

  or

// Using an array assignment
c1 = { 5, 0, 6, 3 };

(Note that zeros must be explicitly given if there are powers of x missing.)

Source#

poly.src

See also

Functions polymake(), polychar(), polyroot(), polyeval()