Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 257

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Finding Roots - 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="Evaluating-Polynomials.html#Evaluating-Polynomials" title="Evaluating Polynomials">
<link rel="next" href="Products-of-Polynomials.html#Products-of-Polynomials" title="Products of Polynomials">
<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="Finding-Roots"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Products-of-Polynomials.html#Products-of-Polynomials">Products of Polynomials</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Evaluating-Polynomials.html#Evaluating-Polynomials">Evaluating Polynomials</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Polynomial-Manipulations.html#Polynomial-Manipulations">Polynomial Manipulations</a>
<hr>
</div>

<h3 class="section">28.2 Finding Roots</h3>

<p>Octave can find the roots of a given polynomial.  This is done by computing
the companion matrix of the polynomial (see the <code>compan</code> function
for a definition), and then finding its eigenvalues.

<!-- roots scripts/polynomial/roots.m -->
   <p><a name="doc_002droots"></a>

<div class="defun">
&mdash; Function File:  <b>roots</b> (<var>v</var>)<var><a name="index-roots-2705"></a></var><br>
<blockquote>
        <p>For a vector <var>v</var> with N components, return
the roots of the polynomial

     <pre class="example">          v(1) * z^(N-1) + ... + v(N-1) * z + v(N)
</pre>
        <p>As an example, the following code finds the roots of the quadratic
polynomial

     <pre class="example">          p(x) = x^2 - 5.
</pre>
        <pre class="example">          c = [1, 0, -5];
          roots (c)
          &rArr;  2.2361
          &rArr; -2.2361
</pre>
        <p>Note that the true result is
+/- sqrt(5)
which is roughly
+/- 2.2361. 
<!-- 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_002dcompan.html#doc_002dcompan">compan</a>, <a href="doc_002dfzero.html#doc_002dfzero">fzero</a>. 
</p></blockquote></div>

<!-- compan scripts/polynomial/compan.m -->
   <p><a name="doc_002dcompan"></a>

<div class="defun">
&mdash; Function File:  <b>compan</b> (<var>c</var>)<var><a name="index-compan-2706"></a></var><br>
<blockquote><p>Compute the companion matrix corresponding to polynomial coefficient
vector <var>c</var>.

        <p>The companion matrix is
<!-- Set example in small font to prevent overfull line -->

     <pre class="smallexample">               _                                                        _
              |  -c(2)/c(1)   -c(3)/c(1)  ...  -c(N)/c(1)  -c(N+1)/c(1)  |
              |       1            0      ...       0             0      |
              |       0            1      ...       0             0      |
          A = |       .            .      .         .             .      |
              |       .            .       .        .             .      |
              |       .            .        .       .             .      |
              |_      0            0      ...       1             0     _|
</pre>
        <p>The eigenvalues of the companion matrix are equal to the roots of the
polynomial. 
<!-- 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_002droots.html#doc_002droots">roots</a>, <a href="doc_002dpoly.html#doc_002dpoly">poly</a>, <a href="doc_002deig.html#doc_002deig">eig</a>. 
</p></blockquote></div>

<!-- mpoles scripts/polynomial/mpoles.m -->
   <p><a name="doc_002dmpoles"></a>

<div class="defun">
&mdash; Function File: [<var>multp</var>, <var>idxp</var>] = <b>mpoles</b> (<var>p</var>)<var><a name="index-mpoles-2707"></a></var><br>
&mdash; Function File: [<var>multp</var>, <var>idxp</var>] = <b>mpoles</b> (<var>p, tol</var>)<var><a name="index-mpoles-2708"></a></var><br>
&mdash; Function File: [<var>multp</var>, <var>idxp</var>] = <b>mpoles</b> (<var>p, tol, reorder</var>)<var><a name="index-mpoles-2709"></a></var><br>
<blockquote><p>Identify unique poles in <var>p</var> and their associated multiplicity.  The
output is ordered from largest pole to smallest pole.

        <p>If the relative difference of two poles is less than <var>tol</var> then
they are considered to be multiples.  The default value for <var>tol</var>
is 0.001.

        <p>If the optional parameter <var>reorder</var> is zero, poles are not sorted.

        <p>The output <var>multp</var> is a vector specifying the multiplicity of the
poles.  <var>multp</var><code>(n)</code> refers to the multiplicity of the Nth pole
<var>p</var><code>(</code><var>idxp</var><code>(n))</code>.

        <p>For example:

     <pre class="example">          p = [2 3 1 1 2];
          [m, n] = mpoles (p)
             &rArr; m = [1; 1; 2; 1; 2]
             &rArr; n = [2; 5; 1; 4; 3]
             &rArr; p(n) = [3, 2, 2, 1, 1]
</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_002dresidue.html#doc_002dresidue">residue</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>