ZEROPOLY Function (PV-WAVE Advantage)
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—Array containing coefficients of the polynomial in increasing order by degree. The polynomial is coef (n) zn + coef (n – 1) zn – 1 + ... + coef (0).
Returned Value
result —The complex array of zeros of the polynomial.
Input Keywords
Double—If present and nonzero, double precision is used.
Companion—If present and nonzero, the companion matrix method is used. Default: companion matrix method
Jenkins_Traub—If present and nonzero, the Jenkins-Traub, three-stage algorithm is used.
Discussion
Function ZEROPOLY computes the n zeros of the polynomial:
p (z) = an zn + an – 1zn – 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 (zI – Ca) = a(z), where I is an n x n identity matrix. Thus, det (z0I – Ca) = 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, then ZEROPOLY function 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.
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 results.
PM, zeros, Title = 'The complex zeros found are: '
; This results in the following output:
; The complex zeros found are:
; ( 1.00000, 0.00000)
; ( 1.00000, -1.00000)
; ( 1.00000, 1.00000)
Warning Errors
MATH_ZERO_COEFF—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 vector contains the value for machine infinity in the locations that do not contain zeros.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.