NAG CL Interface
c02afc (poly_​complex)

Note: this function is deprecated. Replaced by c02aac.

Old Code

Complex a[n+1], z[n];
Nag_Boolean scale;
...
scale = Nag_True;
nag_zeros_poly_complex(n, a, scale, z, &fail);

New Code

Complex a[n+1], z[n];
Integer itmax;
Nag_Root_Polish polish;
double berr[n], cond[n];
Integer conv[n];
...
itmax = 30;
polish = Nag_Root_Polish_Simple;
nag_zeros_poly_complex_fpml(a, n, itmax, polish, z, berr, cond, conv, &fail);
that the roots may be returned in a different order in array z.
Settings help

CL Name Style:


1 Purpose

c02afc finds all the roots of a complex polynomial equation, using a variant of Laguerre's method.

2 Specification

#include <nag.h>
void  c02afc (Integer n, const Complex a[], Nag_Boolean scale, Complex z[], NagError *fail)
The function may be called by the names: c02afc, nag_zeros_poly_complex or nag_zeros_complex_poly.

3 Description

c02afc attempts to find all the roots of the n th degree complex polynomial equation
P (z) = a 0 z n + a 1 z n-1 + a 2 z n-2 + + a n-1 z + a n = 0 .  
The roots are located using a modified form of Laguerre's method, originally proposed by Smith (1967).
The method of Laguerre (see Wilkinson (1965)) can be described by the iterative scheme
L ( z k ) = z k+1 - z k = - n P ( z k ) P ( z k ) ± H ( z k ) ,  
where H ( z k ) = (n-1) [(n-1) ( P ( z k )) 2 -nP( z k ) P ( z k )] , and z 0 is specified.
The sign in the denominator is chosen so that the modulus of the Laguerre step at z k , viz. |L( z k )| , is as small as possible. The method can be shown to be cubically convergent for isolated roots (real or complex) and linearly convergent for multiple roots.
The function generates a sequence of iterates z 1 , z 2 , z 3 , , such that |P( z k+1 )| < |P( z k )| and ensures that z k+1 + L ( z k+1 ) ‘roughly’ lies inside a circular region of radius |F| about z k known to contain a zero of P (z) ; that is, |L( z k+1 )| |F| , where F denotes the Fejér bound (see Marden (1966)) at the point z k . Following Smith (1967), F is taken to be min(B,1.445nR) , where B is an upper bound for the magnitude of the smallest zero given by
B = 1.0001 × min( n L ( z k ) ,| r 1 |, | a n / a 0 | 1/n ) ,  
r 1 is the zero X of smaller magnitude of the quadratic equation
( P ( z k )/(2n(n-1))) X 2 + ( P ( z k )/n) X + 1 2 P ( z k ) = 0  
and the Cauchy lower bound R for the smallest zero is computed (using Newton's Method) as the positive root of the polynomial equation
| a 0 | z n + | a 1 | z n-1 + | a 2 | z n-2 + + | a n-1 | z - | a n | = 0 .  
Starting from the origin, successive iterates are generated according to the rule z k+1 = z k + L ( z k ) for k = 1 , 2 , 3 , and L ( z k ) is ‘adjusted’ so that |P( z k+1 )| < |P( z k )| and |L( z k+1 )| |F| . The iterative procedure terminates if P ( z k+1 ) is smaller in absolute value than the bound on the rounding error in P ( z k+1 ) and the current iterate z p = z k+1 is taken to be a zero of P (z) . The deflated polynomial P ~ (z) = P (z) / (z- z p ) of degree n-1 is then formed, and the above procedure is repeated on the deflated polynomial until n<3 , whereupon the remaining roots are obtained via the ‘standard’ closed formulae for a linear ( n=1 ) or quadratic ( n=2 ) equation.

4 References

Marden M (1966) Geometry of polynomials Mathematical Surveys 3 American Mathematical Society, Providence, RI
Smith B T (1967) ZERPOL: a zero finding algorithm for polynomials using Laguerre's method Technical Report Department of Computer Science, University of Toronto, Canada
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford

5 Arguments

1: n Integer Input
On entry: the degree of the polynomial, n .
Constraint: n1 .
2: a[n+1] const Complex Input
On entry: a[i].re and a[i].im must contain the real and imaginary parts of a i (i.e., the coefficient of z n-i ), for i=0,1,,n.
Constraint: a[0].re 0.0 or a[0].im 0.0 .
3: scale Nag_Boolean Input
On entry: indicates whether or not the polynomial is to be scaled. The recommended value is Nag_TRUE. See Section 9 for advice on when it may be preferable to set scale=Nag_FALSE and for a description of the scaling strategy.
4: z[n] Complex Output
On exit: the real and imaginary parts of the roots are stored in z[i].re and z[i].im respectively, for i=0,1,,n - 1.
5: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_COMPLEX_ZERO
On entry, the complex variable a[0] has zero real and imaginary parts.
NE_INT_ARG_LT
On entry, n=value.
Constraint: n1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_POLY_NOT_CONV
The iterative procedure has failed to converge. This error is very unlikely to occur. If it does, please contact NAG immediately, as some basic assumption for the arithmetic has been violated.
NE_POLY_OVFLOW
The function cannot evaluate P (z) near some of its zeros without overflow. Please contact NAG immediately.
NE_POLY_UNFLOW
The function cannot evaluate P (z) near some of its zeros without underflow. Please contact NAG immediately.

7 Accuracy

All roots are evaluated as accurately as possible, but because of the inherent nature of the problem complete accuracy cannot be guaranteed.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
c02afc is not threaded in any implementation.

9 Further Comments

If scale=Nag_TRUE, then a scaling factor for the coefficients is chosen as a power of the base b of the machine so that the largest coefficient in magnitude approaches thresh=bemax-p. You should note that no scaling is performed if the largest coefficient in magnitude exceeds thresh, even if scale=Nag_TRUE. (b, emax and p are defined in Chapter X02.)
However, with scale=Nag_TRUE , overflow may be encountered when the input coefficients a 0 , a 1 , a 2 , , a n vary widely in magnitude, particularly on those machines for which b 4p overflows. In such cases, scale should be set to Nag_FALSE and the coefficients scaled so that the largest coefficient in magnitude does not exceed b e max - 2 p .
Even so, the scaling strategy used in c02afc is sometimes insufficient to avoid overflow and/or underflow conditions. In such cases, you are recommended to scale the independent variable (z) so that the disparity between the largest and smallest coefficient in magnitude is reduced. That is, use the function to locate the zeros of the polynomial d × P (cz) for some suitable values of c and d . For example, if the original polynomial was P (z) = 2 −100 i + 2 100 z 20 , then choosing c = 2 −10 and d = 2 100 , for instance, would yield the scaled polynomial i + z 20 , which is well-behaved relative to overflow and underflow and has zeros which are 2 10 times those of P (z) .
If the function fails with NE_POLY_NOT_CONV, NE_POLY_UNFLOW or NE_POLY_OVFLOW, then the real and imaginary parts of any roots obtained before the failure occurred are stored in z in the reverse order in which they were found. More precisely, z[n-1].re and z[n-1].im contain the real and imaginary parts of the 1st root found, z[n-2].re and z[n-2].im contain the real and imaginary parts of the 2nd root found, and so on. The real and imaginary parts of any roots not found will be set to a large negative number, specifically -1.0 / ( 2.0 ×nag_real_safe_small_number) .

10 Example

To find the roots of the polynomial a 0 z 5 + a 1 z 4 + a 2 z 3 + a 3 z 2 + a 4 z + a 5 = 0 , where a 0 = (5.0+6.0i) , a 1 = (30.0+20.0i) , a 2 = - (0.2+6.0i) , a 3 = (50.0+100000.0i) , a 4 = - (2.0-40.0i) and a 5 = (10.0+1.0i) .

10.1 Program Text

Program Text (c02afce.c)

10.2 Program Data

Program Data (c02afce.d)

10.3 Program Results

Program Results (c02afce.r)