### 27.3 Products of Polynomials

— Function File: conv (a, b)

> Convolve two vectors.

> `y = conv (a, b)` returns a vector of length equal to `length (a) + length (b) - 1`. If a and b are polynomial coefficient vectors, `conv` returns the coefficients of the product polynomial.

> See also: deconv, poly, roots, residue, polyval, polyderiv, polyinteg.

— Function File: deconv (y, a)

> Deconvolve two vectors.

> `[b, r] = deconv (y, a)` solves for b and r such that `y = conv (a, b) + r`.

> If y and a are polynomial coefficient vectors, b will contain the coefficients of the polynomial quotient and r will be a remander polynomial of lowest order.

> See also: conv, poly, roots, residue, polyval, polyderiv, polyinteg.

— Loadable Function: y = conv2 (a, b, shape)
— Loadable Function: y = conv2 (v1, v2, M, shape)

> Returns 2D convolution of a and b where the size of c is given by

> shape= 'full'
>   returns full 2-D convolution
> shape= 'same'
>   same size as a. 'central' part of convolution
> shape= 'valid'
>   only parts which do not include zero-padded edges

> By default shape is 'full'. When the third argument is a matrix returns the convolution of the matrix M by the vector v1 in the column direction and by vector v2 in the row direction

— Function File: q = polygcd (b, a, tol)

> Find greatest common divisor of two polynomials. This is equivalent to the polynomial found by multiplying together all the common roots. Together with deconv, you can reduce a ratio of two polynomials. Tolerance defaults to

>               sqrt(eps).

> Note that this is an unstable algorithm, so don't try it on large polynomials.

> Example

>               polygcd (poly(1:8), poly(3:12)) - poly(3:8)
>               => [ 0, 0, 0, 0, 0, 0, 0 ]
>               deconv (poly(1:8), polygcd (poly(1:8), poly(3:12))) - poly(1:2)
>               => [ 0, 0, 0 ]

> See also: poly, polyinteg, polyderiv, polyreduce, roots, conv, deconv, residue, filter, polyval, and polyvalm.

— Function File: residue (b, a, tol)

> If b and a are vectors of polynomial coefficients, then residue calculates the partial fraction expansion corresponding to the ratio of the two polynomials. The function `residue` returns r, p, k, and e, where the vector r contains the residue terms, p contains the pole values, k contains the coefficients of a direct polynomial term (if it exists) and e is a vector containing the powers of the denominators in the partial fraction terms.

> Assuming b and a represent polynomials P (s) and Q(s) we have:

>                P(s)    M       r(m)         N
>                ---- = SUM -------------  + SUM k(i)*s^(N-i)
>                Q(s)   m=1 (s-p(m))^e(m)    i=1

> where M is the number of poles (the length of the r, p, and e vectors) and N is the length of the k vector.

> The argument tol is optional, and if not specified, a default value of 0.001 is assumed. The tolerance value is used to determine whether poles with small imaginary components are declared real. It is also used to determine if two poles are distinct. If the ratio of the imaginary part of a pole to the real part is less than tol, the imaginary part is discarded. If two poles are farther apart than tol they are distinct. For example,

>                b = [1, 1, 1];
>                a = [1, -5, 8, -4];
>                [r, p, k, e] = residue (b, a);
>               => r = [-2, 7, 3]
>               => p = [2, 2, 1]
>               => k = [](0x0)
>               => e = [1, 2, 1]

> which implies the following partial fraction expansion

>                       s^2 + s + 1       -2        7        3
>                  ------------------- = ----- + ------- + -----
>                  s^3 - 5s^2 + 8s - 4   (s-2)   (s-2)^2   (s-1)

> See also: poly, roots, conv, deconv, polyval, polyderiv, and polyinteg.