IMSL C Math Library
zeros_poly (complex)
Finds the zeros of a polynomial with complex coefficients using the Jenkins-Traub, three-stage algorithm.
Synopsis
#include <imsl.h>
f_complex *imsl_c_zeros_poly (int ndeg, f_complex coef[], , 0)
The type d_complex function is imsl_z_zeros_poly.
Required Arguments
int ndeg (Input)
Degree of the polynomial.
f_complex coef[] (Input)
Array with ndeg + 1 components containing the coefficients of the polynomial in increasing order by degree. The degree of the polynomial is
coef [n] zn + coef [n  1] zn-1 + coef [0]
where n = ndeg.
Return Value
A pointer to the complex array of zeros of the polynomial. To release this space, use imsl_free. If no zeros are computed, then NULL is returned.
Synopsis with Optional Arguments
#include <imsl.h>
f_complex *imsl_c_zeros_poly (int ndeg, f_complex coef[],
IMSL_RETURN_USER, f_complex root[],
0)
Optional Arguments
IMSL_RETURN_USER, f_complex root[] (Output)
Array with ndeg components containing the zeros of the polynomial.
Description
The function imsl_c_zeros_poly computes the n zeros of the polynomial
p(z) = anzn + an-1 zn-1 +  + a1z + a0
where the coefficients ai for i = 0, 1, , n are complex and n is the degree of the polynomial.
The function imsl_c_zeros_poly uses the Jenkins-Traub, three-stage complex algorithm (Jenkins and Traub 1970, 1972). The zeros are computed one at a time in roughly increasing order of modulus. As each zero is found, the polynomial is deflated to one of lower degree.
Examples
Example 1
This example finds the zeros of the third-degree polynomial
p(z) = z3  (3 + 6i) z2  (8  12i) z + 10
where z is a complex variable.
 
#include <imsl.h>
 
#define NDEG 3
 
int main()
{
f_complex *zeros;
f_complex coeff[NDEG + 1] = { {10.0, 0.0},
{-8.0, 12.0},
{-3.0, -6.0},
{ 1.0, 0.0} };
 
zeros = imsl_c_zeros_poly(NDEG, coeff, 0);
 
imsl_c_write_matrix ("The complex zeros found are", 1, 3,
zeros, 0);
}
Output
 
The complex zeros found are
1 2 3
( 1, 1) ( 1, 2) ( 1, 3)
Example 2
The same problem is solved with the return option.
 
#include <imsl.h>
 
#define NDEG 3
 
int main()
{
f_complex zeros[3];
f_complex coeff[NDEG + 1] = { {10.0, 0.0},
{-8.0, 12.0},
{-3.0, -6.0},
{ 1.0, 0.0} };
 
imsl_c_zeros_poly(NDEG, coeff, IMSL_RETURN_USER, zeros, 0);
 
imsl_c_write_matrix ("The complex zeros found are", 1, 3,
zeros, 0);
}
Output
 
The complex zeros found are
1 2 3
( 1, 1) ( 1, 2) ( 1, 3)
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.