NAG FL Interface
c02aff (poly_complex)
1
Purpose
c02aff finds all the roots of a complex polynomial equation, using a variant of Laguerre's method.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
n |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
a(2,n+1) |
Real (Kind=nag_wp), Intent (Out) |
:: |
z(2,n), w(4*(n+1)) |
Logical, Intent (In) |
:: |
scal |
|
C Header Interface
#include <nag.h>
void |
c02aff_ (const double a[], const Integer *n, const logical *scal, double z[], double w[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
c02aff_ (const double a[], const Integer &n, const logical &scal, double z[], double w[], Integer &ifail) |
}
|
The routine may be called by the names c02aff or nagf_zeros_poly_complex.
3
Description
c02aff attempts to find all the roots of the
th degree complex polynomial equation
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
where
and
is specified.
The sign in the denominator is chosen so that the modulus of the Laguerre step at , viz. , 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 routine generates a sequence of iterates
, such that
and ensures that
‘roughly’ lies inside a circular region of radius
about
known to contain a zero of
; that is,
, where
denotes the Fejér bound (see
Marden (1966)) at the point
. Following
Smith (1967),
is taken to be
, where
is an upper bound for the magnitude of the smallest zero given by
is the zero
of smaller magnitude of the quadratic equation
and the Cauchy lower bound
for the smallest zero is computed (using Newton's Method) as the positive root of the polynomial equation
Starting from the origin, successive iterates are generated according to the rule
, for
, and
is ‘adjusted’ so that
and
. The iterative procedure terminates if
is smaller in absolute value than the bound on the rounding error in
and the current iterate
is taken to be a zero of . The deflated polynomial
of degree is then formed, and the above procedure is repeated on the deflated polynomial until , whereupon the remaining roots are obtained via the ‘standard’ closed formulae for a linear () or quadratic () equation.
Note that
c02ahf,
c02amf and
c02anf can be used to obtain the roots of a quadratic, cubic (
) and quartic (
) polynomial, respectively.
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
Thompson K W (1991) Error analysis for polynomial solvers Fortran Journal (Volume 3) 3 10–13
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford
5
Arguments
-
1:
– Real (Kind=nag_wp) array
Input
-
On entry: if
a is declared with bounds
,
and
must contain the real and imaginary parts of
(i.e., the coefficient of
), for
.
Constraint:
or .
-
2:
– Integer
Input
-
On entry: , the degree of the polynomial.
Constraint:
.
-
3:
– Logical
Input
-
On entry: indicates whether or not the polynomial is to be scaled. See
Section 9 for advice on when it may be preferable to set
and for a description of the scaling strategy.
Suggested value:
.
-
4:
– Real (Kind=nag_wp) array
Output
-
On exit: the real and imaginary parts of the roots are stored in
and respectively, for .
-
5:
– Real (Kind=nag_wp) array
Workspace
-
-
6:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, and .
Constraint: or .
On entry, .
Constraint: .
-
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.
-
c02aff cannot evaluate
near some of its zeros without overflow. If this message occurs please contact
NAG.
c02aff cannot evaluate
near some of its zeros without underflow. If this message occurs please contact
NAG.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
All roots are evaluated as accurately as possible, but because of the inherent nature of the problem complete accuracy cannot be guaranteed.
See also
Section 10.
8
Parallelism and Performance
c02aff is not threaded in any implementation.
If
, then a scaling factor for the coefficients is chosen as a power of the base
of the machine so that the largest coefficient in magnitude approaches
. You should note that no scaling is performed if the largest coefficient in magnitude exceeds
, even if
. (
,
and
are defined in
Chapter X02.)
However, with
, overflow may be encountered when the input coefficients
vary widely in magnitude, particularly on those machines for which
overflows. In such cases,
scal should be set to .FALSE. and the coefficients scaled so that the largest coefficient in magnitude does not exceed
.
Even so, the scaling strategy used by c02aff is sometimes insufficient to avoid overflow and/or underflow conditions. In such cases, you are recommended to scale the independent variable so that the disparity between the largest and smallest coefficient in magnitude is reduced. That is, use the routine to locate the zeros of the polynomial for some suitable values of and . For example, if the original polynomial was , then choosing and , for instance, would yield the scaled polynomial , which is well-behaved relative to overflow and underflow and has zeros which are times those of .
If the routine fails with
or
, 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.
Let
denote the number of roots found before the failure occurred. Then
and
contain the real and imaginary parts of the first root found,
and
contain the real and imaginary parts of the second root found,
and
contain the real and imaginary parts of the
th root found. After the failure has occurred, the remaining
elements of
z contain a large negative number (equal to
).
10
Example
For this routine two examples are presented. There is a single example program for c02aff, with a main program and the code to solve the two example problems given in the subroutines EX1 and EX2.
Example 1 (EX1)
This example finds the roots of the polynomial
where
,
,
,
,
and
.
Example 2 (EX2)
This example solves the same problem as subroutine EX1, but in addition attempts to estimate the accuracy of the computed roots using a perturbation analysis. Further details can be found in
Thompson (1991).
10.1
Program Text
10.2
Program Data
10.3
Program Results