poly - Polynomial with specified roots or characteristic polynomial - MATLAB (original) (raw)

Polynomial with specified roots or characteristic polynomial

Syntax

Description

[p](#busoogs-p) = poly([r](#busoogs-r)), where r is a vector, returns the coefficients of the polynomial whose roots are the elements of r.

example

[p](#busoogs-p) = poly([A](#busoogs-A)), where A is an n-by-n matrix, returns the n+1 coefficients of the characteristic polynomial of the matrix, det(λIA).

example

Examples

collapse all

Calculate the eigenvalues of a matrix, A.

A = [1 8 -10; -4 2 4; -5 2 8]

A = 3×3

 1     8   -10
-4     2     4
-5     2     8

e = 3×1 complex

11.6219 + 0.0000i -0.3110 + 2.6704i -0.3110 - 2.6704i

Since the eigenvalues in e are the roots of the characteristic polynomial of A, use poly to determine the characteristic polynomial from the values in e.

p = 1×4

1.0000  -11.0000   -0.0000  -84.0000

Use poly to calculate the characteristic polynomial of a matrix, A.

A = [1 2 3; 4 5 6; 7 8 0]

A = 3×3

 1     2     3
 4     5     6
 7     8     0

p = 1×4

1.0000   -6.0000  -72.0000  -27.0000

Calculate the roots of p using roots. The roots of the characteristic polynomial are the eigenvalues of matrix A.

r = 3×1

12.1229 -5.7345 -0.3884

Input Arguments

collapse all

Polynomial roots, specified as a vector.

Example: poly([2 -3])

Example: poly([2 -2 3 -3])

Example: poly(roots(k))

Example: poly(eig(A))

Data Types: single | double
Complex Number Support: Yes

Input matrix.

Example: poly([0 -1; 1 0])

Data Types: single | double
Complex Number Support: Yes

Output Arguments

collapse all

Polynomial coefficients, returned as a row vector.

In each case, the n+1 coefficients in p describe the polynomial

Tips

Algorithms

The algorithms employed for poly and roots illustrate an interesting aspect of the modern approach to eigenvalue computation. poly(A) generates the characteristic polynomial of A, and roots(poly(A)) finds the roots of that polynomial, which are the eigenvalues of A. But both poly and roots use eig, which is based on similarity transformations. The classical approach, which characterizes eigenvalues as roots of the characteristic polynomial, is actually reversed.

If A is an n-by-n matrix, poly(A) produces the coefficients p(1) through p(n+1), with p(1) = 1, in

The algorithm is

z = eig(A); p = zeros(n+1,1); p(1) = 1; for j = 1:n p(2:j+1) = p(2:j+1)-z(j)*p(1:j); end

This recursion is derived by expanding the product,

It is possible to prove that poly(A) produces the coefficients in the characteristic polynomial of a matrix within roundoff error of A. This is true even if the eigenvalues of A are badly conditioned. The traditional algorithms for obtaining the characteristic polynomial do not use the eigenvalues, and do not have such satisfactory numerical properties.

Extended Capabilities

expand all

Usage notes and limitations:

The poly function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a