<html lang="en"> <head> <title>Miscellaneous Functions - 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="Polynomial-Interpolation.html#Polynomial-Interpolation" title="Polynomial Interpolation"> <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="Miscellaneous-Functions"></a> <p> Previous: <a rel="previous" accesskey="p" href="Polynomial-Interpolation.html#Polynomial-Interpolation">Polynomial Interpolation</a>, Up: <a rel="up" accesskey="u" href="Polynomial-Manipulations.html#Polynomial-Manipulations">Polynomial Manipulations</a> <hr> </div> <h3 class="section">28.6 Miscellaneous Functions</h3> <!-- poly scripts/polynomial/poly.m --> <p><a name="doc_002dpoly"></a> <div class="defun"> — Function File: <b>poly</b> (<var>A</var>)<var><a name="index-poly-2741"></a></var><br> — Function File: <b>poly</b> (<var>x</var>)<var><a name="index-poly-2742"></a></var><br> <blockquote><p>If <var>A</var> is a square N-by-N matrix, <code>poly (</code><var>A</var><code>)</code> is the row vector of the coefficients of <code>det (z * eye (N) - A)</code>, the characteristic polynomial of <var>A</var>. For example, the following code finds the eigenvalues of <var>A</var> which are the roots of <code>poly (</code><var>A</var><code>)</code>. <pre class="example"> roots (poly (eye (3))) ⇒ 1.00001 + 0.00001i 1.00001 - 0.00001i 0.99999 + 0.00000i </pre> <p>In fact, all three eigenvalues are exactly 1 which emphasizes that for numerical performance the <code>eig</code> function should be used to compute eigenvalues. <p>If <var>x</var> is a vector, <code>poly (</code><var>x</var><code>)</code> is a vector of the coefficients of the polynomial whose roots are the elements of <var>x</var>. That is, if <var>c</var> is a polynomial, then the elements of <var>d</var><code> = roots (poly (</code><var>c</var><code>))</code> are contained in <var>c</var>. The vectors <var>c</var> and <var>d</var> are not identical, however, due to sorting and numerical errors. <!-- 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_002deig.html#doc_002deig">eig</a>. </p></blockquote></div> <!-- polyout scripts/polynomial/polyout.m --> <p><a name="doc_002dpolyout"></a> <div class="defun"> — Function File: <b>polyout</b> (<var>c</var>)<var><a name="index-polyout-2743"></a></var><br> — Function File: <b>polyout</b> (<var>c, x</var>)<var><a name="index-polyout-2744"></a></var><br> — Function File: <var>str</var> = <b>polyout</b> (<var><small class="dots">...</small></var>)<var><a name="index-polyout-2745"></a></var><br> <blockquote><p>Write formatted polynomial <pre class="example"> c(x) = c(1) * x^n + ... + c(n) x + c(n+1) </pre> <p>and return it as a string or write it to the screen (if <var>nargout</var> is zero). <var>x</var> defaults to the string <code>"s"</code>. <!-- 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_002dpolyreduce.html#doc_002dpolyreduce">polyreduce</a>. </p></blockquote></div> <!-- polyreduce scripts/polynomial/polyreduce.m --> <p><a name="doc_002dpolyreduce"></a> <div class="defun"> — Function File: <b>polyreduce</b> (<var>c</var>)<var><a name="index-polyreduce-2746"></a></var><br> <blockquote><p>Reduce a polynomial coefficient vector to a minimum number of terms by stripping off any leading zeros. <!-- 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_002dpolyout.html#doc_002dpolyout">polyout</a>. </p></blockquote></div> <!-- DO NOT EDIT! Generated automatically by munge-texi.pl. --> <!-- Copyright (C) 2007-2012 John W. Eaton --> <!-- This file is part of Octave. --> <!-- Octave is free software; you can redistribute it and/or modify it --> <!-- under the terms of the GNU General Public License as published by the --> <!-- Free Software Foundation; either version 3 of the License, or (at --> <!-- your option) any later version. --> <!-- Octave is distributed in the hope that it will be useful, but WITHOUT --> <!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or --> <!-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --> <!-- for more details. --> <!-- You should have received a copy of the GNU General Public License --> <!-- along with Octave; see the file COPYING. If not, see --> <!-- <http://www.gnu.org/licenses/>. --> </body></html>