NAG Library Routine Document

c02anf (quartic_complex)


    1  Purpose
    7  Accuracy


c02anf determines the roots of a quartic equation with complex coefficients.


Fortran Interface
Subroutine c02anf ( e, a, b, c, d, zeror, zeroi, errest, ifail)
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (Out):: zeror(4), zeroi(4), errest(4)
Complex (Kind=nag_wp), Intent (In):: e, a, b, c, d
C Header Interface
#include nagmk26.h
void  c02anf_ (const Complex *e, const Complex *a, const Complex *b, const Complex *c, const Complex *d, double zeror[], double zeroi[], double errest[], Integer *ifail)


c02anf attempts to find the roots of the quartic equation
where e, a, b, c and d are complex coefficients with e0. The roots are located by finding the eigenvalues of the associated 4 by 4 (upper Hessenberg) companion matrix H given by
H= 0 0 0 -d/e 1 0 0 -c/e 0 1 0 -b/e 0 0 1 -a/e .  
The eigenvalues are obtained by a call to f08psf (zhseqr). Further details can be found in Section 9.
To obtain the roots of a cubic equation, c02amf can be used.


Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore


1:     e – Complex (Kind=nag_wp)Input
On entry: e, the coefficient of z4.
Constraint: e0.0,0.0.
2:     a – Complex (Kind=nag_wp)Input
On entry: a, the coefficient of z3.
3:     b – Complex (Kind=nag_wp)Input
On entry: b, the coefficient of z2.
4:     c – Complex (Kind=nag_wp)Input
On entry: c, the coefficient of z.
5:     d – Complex (Kind=nag_wp)Input
On entry: d, the constant coefficient.
6:     zeror4 – Real (Kind=nag_wp) arrayOutput
7:     zeroi4 – Real (Kind=nag_wp) arrayOutput
On exit: zerori and zeroii contain the real and imaginary parts, respectively, of the ith root.
8:     errest4 – Real (Kind=nag_wp) arrayOutput
On exit: erresti contains an approximate error estimate for the ith root.
9:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry,e=0.0,0.0.
The companion matrix H cannot be formed without overflow.
The iterative procedure used to determine the eigenvalues has failed to converge.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


If ifail=0 on exit, then the ith computed root should have approximately log10erresti  correct significant digits.

Parallelism and Performance

c02anf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
c02anf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Further Comments

The method used by the routine consists of the following steps, which are performed by routines from LAPACK in Chapter F08.
(a) Form matrix H.
(b) Apply a diagonal similarity transformation to H (to give H).
(c) Calculate the eigenvalues and Schur factorization of H.
(d) Calculate the left and right eigenvectors of H.
(e) Estimate reciprocal condition numbers for all the eigenvalues of H.
(f) Calculate approximate error estimates for all the eigenvalues of H (using the 1-norm).


This example finds the roots of the quartic equation

Program Text

Program Text (c02anfe.f90)

Program Data

Program Data (c02anfe.d)

Program Results

Program Results (c02anfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017