ZEROPOLY Function

Finds the zeros of a polynomial with real or complex coefficients using the companion matrix method or, optionally, the Jenkins-Traub, three-stage algorithm.

Usage

result = ZEROPOLY(coef)

Input Parameters

coef—An array containing the coefficients of the polynomial in increasing order by degree. The polynomial is of the form:

coef (n) zn + coef (n – 1) z(n – 1) + ¼ + coef (0)

Returned Value

result—The complex array of zeros of the polynomial.

Keywords

Companion—If present and nonzero, the companion matrix method is used. (Default: companion matrix method)

Double—If present and nonzero, double precision is used.

Jenkins_Traub—If present and nonzero, the Jenkins-Traub, three-stage algorithm is used.

Discussion

ZEROPOLY computes the n zeros of the polynomial

p (z) = an zn + an – 1z(n – 1) + ... + a1 z + a0

where the coefficients ai for i = 0, 1, ... , n  are real and n is the degree of the polynomial.

The default method used by ZEROPOLY is the companion matrix method. The companion matrix method is based on the fact that if Ca denotes the companion matrix associated with p(z), then
det (zICa) = p(z), where I  is an  n-by-n  identity matrix. Thus,
det (z0ICa) = 0  if, and only if, z0 is a zero of p(z). This implies that computing the eigenvalues of Ca will yield the zeros of p(z). This method is thought to be more robust than the Jenkins-Traub algorithm in most cases, but the companion matrix method is not as computationally efficient. Thus, if speed is a concern, the Jenkins-Traub algorithm should be considered.

If the keyword Jenkins_Traub is set, ZEROPOLY uses the Jenkins-Traub three-stage algorithm (Jenkins and Traub, 1970; Jenkins, 1975). The zeros are computed one-at-a-time for real zeros or two-at-a-time for a complex conjugate pair. As the zeros are found, the real zero or quadratic factor is removed by polynomial deflation.

Warning Errors

MATH_ZERO_COEFF—The first several coefficients of the polynomial are equal to zero. Several of the last roots are set to machine infinity to compensate for this problem.

MATH_FEWER_ZEROS_FOUND—Fewer than (N_ELEMENTS (coef) – 1) zeros were found. The root array contains the value for machine infinity in the locations that do not contain zeros.

Example

This example finds the zeros of the third-degree polynomial:

p (z) = z3 – 3z2 + 4z – 2

where z is a complex variable.

; Set the coefficients.
coef = [-2, 4, -3, 1]
; Compute the zeros.
zeros = ZEROPOLY(coef)
; Print the complex polynomial results.
PM, zeros, Title = 'The complex zeros found are: '
; PV-WAVE prints the following:
; The complex zeros found are:
; (      1.00000,      0.00000)
; (      1.00000,     -1.00000)
; (      1.00000,      1.00000)

See Also

ROOT2POLY

For Additional Information

Jenkins, 1975.

Jenkins and Traub, 1970.