zerosPoly

Finds the zeros of a polynomial with real coefficients using the Jenkins-Traub, three-stage algorithm.

Synopsis

zerosPoly (coef)

Required Arguments

float coef[] (Input)
Array with ndeg + 1 components containing the coefficients of the polynomial in increasing order by degree. The polynomial is coef[n] \(z^n\) + coef [n − 1] \(z_n n-^1\) + … + coef[0], where n = ndeg.

Return Value

The complex array of zeros of the polynomial. If no zeros are computed, then None is returned.

Description

The function zerosPoly computes the n zeros of the polynomial

\[p(z) = a_n z^n + a_{n-1} z^{n-1} + \ldots + a_1z + a_0\]

where the coefficients \(a_i\) for \(i=0,1,\ldots,n\) are real and n is the degree of the polynomial.

The function zerosPoly 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) = z^3 − 3z^2 + 4z – 2\]

where z is a complex variable.

from numpy import *
from pyimsl.math.zerosPoly import zerosPoly
from pyimsl.math.writeMatrixComplex import writeMatrixComplex

coeff = [-2.0, 4.0, -3.0, 1.0]
zeros = zerosPoly(coeff)
writeMatrixComplex("The complex zeros found are", zeros)

Output

 
             The complex zeros found are
                        1                          2
(          1,          0)  (          1,          1)
 
                        3
(          1,         -1)

Warning Errors

IMSL_ZERO_COEFF The first several coefficients of the polynomial are equal to zero. Several of the last roots will be set to machine infinity to compensate for this problem.
IMSL_FEWER_ZEROS_FOUND Fewer than ndeg zeros were found. The root vector will contain the value for machine infinity in the locations that do not contain zeros.