<html lang="en"> <head> <title>Products of Polynomials - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Polynomial-Manipulations.html#Polynomial-Manipulations" title="Polynomial Manipulations"> <link rel="prev" href="Finding-Roots.html#Finding-Roots" title="Finding Roots"> <link rel="next" href="Derivatives-_002f-Integrals-_002f-Transforms.html#Derivatives-_002f-Integrals-_002f-Transforms" title="Derivatives / Integrals / Transforms"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Products-of-Polynomials"></a> <p> Next: <a rel="next" accesskey="n" href="Derivatives-_002f-Integrals-_002f-Transforms.html#Derivatives-_002f-Integrals-_002f-Transforms">Derivatives / Integrals / Transforms</a>, Previous: <a rel="previous" accesskey="p" href="Finding-Roots.html#Finding-Roots">Finding Roots</a>, Up: <a rel="up" accesskey="u" href="Polynomial-Manipulations.html#Polynomial-Manipulations">Polynomial Manipulations</a> <hr> </div> <h3 class="section">28.3 Products of Polynomials</h3> <!-- conv scripts/polynomial/conv.m --> <p><a name="doc_002dconv"></a> <div class="defun"> — Function File: <b>conv</b> (<var>a, b</var>)<var><a name="index-conv-2710"></a></var><br> — Function File: <b>conv</b> (<var>a, b, shape</var>)<var><a name="index-conv-2711"></a></var><br> <blockquote><p>Convolve two vectors <var>a</var> and <var>b</var>. <p>The output convolution is a vector with length equal to <code>length (</code><var>a</var><code>) + length (</code><var>b</var><code>) - 1</code>. When <var>a</var> and <var>b</var> are the coefficient vectors of two polynomials, the convolution represents the coefficient vector of the product polynomial. <p>The optional <var>shape</var> argument may be <dl> <dt><var>shape</var> = "full"<dd>Return the full convolution. (default) <br><dt><var>shape</var> = "same"<dd>Return the central part of the convolution with the same size as <var>a</var>. </dl> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002ddeconv.html#doc_002ddeconv">deconv</a>, <a href="doc_002dconv2.html#doc_002dconv2">conv2</a>, <a href="doc_002dconvn.html#doc_002dconvn">convn</a>, <a href="doc_002dfftconv.html#doc_002dfftconv">fftconv</a>. </p></blockquote></div> <!-- convn src/DLD-FUNCTIONS/conv2.cc --> <p><a name="doc_002dconvn"></a> <div class="defun"> — Loadable Function: <var>C</var> = <b>convn</b> (<var>A, B</var>)<var><a name="index-convn-2712"></a></var><br> — Loadable Function: <var>C</var> = <b>convn</b> (<var>A, B, shape</var>)<var><a name="index-convn-2713"></a></var><br> <blockquote><p>Return the n-D convolution of <var>A</var> and <var>B</var>. The size of the result is determined by the optional <var>shape</var> argument which takes the following values <dl> <dt><var>shape</var> = "full"<dd>Return the full convolution. (default) <br><dt><var>shape</var> = "same"<dd>Return central part of the convolution with the same size as <var>A</var>. The central part of the convolution begins at the indices <code>floor ([size(</code><var>B</var><code>)/2] + 1)</code>. <br><dt><var>shape</var> = "valid"<dd>Return only the parts which do not include zero-padded edges. The size of the result is <code>max (size (A) - size (B) + 1, 0)</code>. </dl> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dconv2.html#doc_002dconv2">conv2</a>, <a href="doc_002dconv.html#doc_002dconv">conv</a>. </p></blockquote></div> <!-- deconv scripts/polynomial/deconv.m --> <p><a name="doc_002ddeconv"></a> <div class="defun"> — Function File: <b>deconv</b> (<var>y, a</var>)<var><a name="index-deconv-2714"></a></var><br> <blockquote><p>Deconvolve two vectors. <p><code>[b, r] = deconv (y, a)</code> solves for <var>b</var> and <var>r</var> such that <code>y = conv (a, b) + r</code>. <p>If <var>y</var> and <var>a</var> are polynomial coefficient vectors, <var>b</var> will contain the coefficients of the polynomial quotient and <var>r</var> will be a remainder polynomial of lowest order. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dconv.html#doc_002dconv">conv</a>, <a href="doc_002dresidue.html#doc_002dresidue">residue</a>. </p></blockquote></div> <!-- conv2 src/DLD-FUNCTIONS/conv2.cc --> <p><a name="doc_002dconv2"></a> <div class="defun"> — Loadable Function: <b>conv2</b> (<var>A, B</var>)<var><a name="index-conv2-2715"></a></var><br> — Loadable Function: <b>conv2</b> (<var>v1, v2, m</var>)<var><a name="index-conv2-2716"></a></var><br> — Loadable Function: <b>conv2</b> (<var><small class="dots">...</small>, shape</var>)<var><a name="index-conv2-2717"></a></var><br> <blockquote><p>Return the 2-D convolution of <var>A</var> and <var>B</var>. The size of the result is determined by the optional <var>shape</var> argument which takes the following values <dl> <dt><var>shape</var> = "full"<dd>Return the full convolution. (default) <br><dt><var>shape</var> = "same"<dd>Return the central part of the convolution with the same size as <var>A</var>. The central part of the convolution begins at the indices <code>floor ([size(</code><var>B</var><code>)/2] + 1)</code>. <br><dt><var>shape</var> = "valid"<dd>Return only the parts which do not include zero-padded edges. The size of the result is <code>max (size (A) - size (B) + 1, 0)</code>. </dl> <p>When the third argument is a matrix, return the convolution of the matrix <var>m</var> by the vector <var>v1</var> in the column direction and by the vector <var>v2</var> in the row direction. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dconv.html#doc_002dconv">conv</a>, <a href="doc_002dconvn.html#doc_002dconvn">convn</a>. </p></blockquote></div> <!-- polygcd scripts/polynomial/polygcd.m --> <p><a name="doc_002dpolygcd"></a> <div class="defun"> — Function File: <var>q</var> = <b>polygcd</b> (<var>b, a</var>)<var><a name="index-polygcd-2718"></a></var><br> — Function File: <var>q</var> = <b>polygcd</b> (<var>b, a, tol</var>)<var><a name="index-polygcd-2719"></a></var><br> <blockquote> <p>Find the 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. The tolerance <var>tol</var> defaults to <code>sqrt(eps)</code>. <p><strong>Caution:</strong> This is a numerically unstable algorithm and should not be used on large polynomials. <p>Example code: <pre class="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 ] </pre> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dpoly.html#doc_002dpoly">poly</a>, <a href="doc_002droots.html#doc_002droots">roots</a>, <a href="doc_002dconv.html#doc_002dconv">conv</a>, <a href="doc_002ddeconv.html#doc_002ddeconv">deconv</a>, <a href="doc_002dresidue.html#doc_002dresidue">residue</a>. </p></blockquote></div> <!-- residue scripts/polynomial/residue.m --> <p><a name="doc_002dresidue"></a> <div class="defun"> — Function File: [<var>r</var>, <var>p</var>, <var>k</var>, <var>e</var>] = <b>residue</b> (<var>b, a</var>)<var><a name="index-residue-2720"></a></var><br> — Function File: [<var>b</var>, <var>a</var>] = <b>residue</b> (<var>r, p, k</var>)<var><a name="index-residue-2721"></a></var><br> — Function File: [<var>b</var>, <var>a</var>] = <b>residue</b> (<var>r, p, k, e</var>)<var><a name="index-residue-2722"></a></var><br> <blockquote><p>The first calling form computes the partial fraction expansion for the quotient of the polynomials, <var>b</var> and <var>a</var>. <pre class="example"> B(s) M r(m) N ---- = SUM ------------- + SUM k(i)*s^(N-i) A(s) m=1 (s-p(m))^e(m) i=1 </pre> <p class="noindent">where M is the number of poles (the length of the <var>r</var>, <var>p</var>, and <var>e</var>), the <var>k</var> vector is a polynomial of order N-1 representing the direct contribution, and the <var>e</var> vector specifies the multiplicity of the m-th residue's pole. <p>For example, <pre class="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] </pre> <p class="noindent">which represents the following partial fraction expansion <pre class="example"> s^2 + s + 1 -2 7 3 ------------------- = ----- + ------- + ----- s^3 - 5s^2 + 8s - 4 (s-2) (s-2)^2 (s-1) </pre> <p>The second calling form performs the inverse operation and computes the reconstituted quotient of polynomials, <var>b</var>(s)/<var>a</var>(s), from the partial fraction expansion; represented by the residues, poles, and a direct polynomial specified by <var>r</var>, <var>p</var> and <var>k</var>, and the pole multiplicity <var>e</var>. <p>If the multiplicity, <var>e</var>, is not explicitly specified the multiplicity is determined by the function <code>mpoles</code>. <p>For example: <pre class="example"> r = [-2; 7; 3]; p = [2; 2; 1]; k = [1, 0]; [b, a] = residue (r, p, k) ⇒ b = [1, -5, 9, -3, 1] ⇒ a = [1, -5, 8, -4] where mpoles is used to determine e = [1; 2; 1] </pre> <p>Alternatively the multiplicity may be defined explicitly, for example, <pre class="example"> r = [7; 3; -2]; p = [2; 1; 2]; k = [1, 0]; e = [2; 1; 1]; [b, a] = residue (r, p, k, e) ⇒ b = [1, -5, 9, -3, 1] ⇒ a = [1, -5, 8, -4] </pre> <p class="noindent">which represents the following partial fraction expansion <pre class="example"> -2 7 3 s^4 - 5s^3 + 9s^2 - 3s + 1 ----- + ------- + ----- + s = -------------------------- (s-2) (s-2)^2 (s-1) s^3 - 5s^2 + 8s - 4 </pre> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dmpoles.html#doc_002dmpoles">mpoles</a>, <a href="doc_002dpoly.html#doc_002dpoly">poly</a>, <a href="doc_002droots.html#doc_002droots">roots</a>, <a href="doc_002dconv.html#doc_002dconv">conv</a>, <a href="doc_002ddeconv.html#doc_002ddeconv">deconv</a>. </p></blockquote></div> </body></html>