octave: Finding Roots
28.2 Finding Roots
==================
Octave can find the roots of a given polynomial. This is done by
computing the companion matrix of the polynomial (see the ‘compan’
function for a definition), and then finding its eigenvalues.
-- : roots (C)
Compute the roots of the polynomial C.
For a vector C with N components, return the roots of the
polynomial
c(1) * x^(N-1) + ... + c(N-1) * x + c(N)
As an example, the following code finds the roots of the quadratic
polynomial
p(x) = x^2 - 5.
c = [1, 0, -5];
roots (c)
⇒ 2.2361
⇒ -2.2361
Note that the true result is +/- sqrt(5) which is roughly +/-
2.2361.
DONTPRINTYET See also: poly XREFpoly, compan XREFcompan, *noteDONTPRINTYET See also: poly XREFpoly, compan XREFcompan,
fzero XREFfzero.
-- : Z = polyeig (C0, C1, ..., CL)
-- : [V, Z] = polyeig (C0, C1, ..., CL)
Solve the polynomial eigenvalue problem of degree L.
Given an N*N matrix polynomial
‘C(s) = C0 + C1 s + ... + CL s^l’
‘polyeig’ solves the eigenvalue problem
‘(C0 + C1 + ... + CL)v = 0’.
Note that the eigenvalues Z are the zeros of the matrix polynomial.
Z is a row vector with N*L elements. V is a matrix (N x N*L) with
columns that correspond to the eigenvectors.
DONTPRINTYET See also: eig XREFeig, eigs XREFeigs, *notecompan:
DONTPRINTYET See also: eig XREFeig, eigs XREFeigs, compan
XREFcompan.
-- : compan (C)
Compute the companion matrix corresponding to polynomial
coefficient vector C.
The companion matrix is
_ _
| -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 _|
The eigenvalues of the companion matrix are equal to the roots of
the polynomial.
DONTPRINTYET See also: roots XREFroots, poly XREFpoly, *noteeig:
DONTPRINTYET See also: roots XREFroots, poly XREFpoly, eig
XREFeig.
-- : [MULTP, IDXP] = mpoles (P)
-- : [MULTP, IDXP] = mpoles (P, TOL)
-- : [MULTP, IDXP] = mpoles (P, TOL, REORDER)
Identify unique poles in P and their associated multiplicity.
The output is ordered from largest pole to smallest pole.
If the relative difference of two poles is less than TOL then they
are considered to be multiples. The default value for TOL is
0.001.
If the optional parameter REORDER is zero, poles are not sorted.
The output MULTP is a vector specifying the multiplicity of the
poles. ‘MULTP(n)’ refers to the multiplicity of the Nth pole
‘P(IDXP(n))’.
For example:
p = [2 3 1 1 2];
[m, n] = mpoles (p)
⇒ m = [1; 1; 2; 1; 2]
⇒ n = [2; 5; 1; 4; 3]
⇒ p(n) = [3, 2, 2, 1, 1]
DONTPRINTYET See also: residue XREFresidue, poly XREFpoly, *noteDONTPRINTYET See also: residue XREFresidue, poly XREFpoly,
roots XREFroots, conv XREFconv, deconv XREFdeconv.