# ccubsolv.f

The CCUBSOLV(A,Z) routine solves the cubic polynomial equation [1]

*z*^{3} + *c*_{2} *z*^{2}
+ *c*_{1} *z* + *c*_{0} = 0,

for general complex coefficients *c*_{k}. The routine
takes a vector A(1..3) of COMPLEX*8 floating point
precision as input, containing the *c*_{k} coefficients
as conforming to the convention

A(1) = *c*_{0},
A(2) = *c*_{1},
A(3) = *c*_{2},

and returns the three complex-valued roots for *z* in the
vector Z(1..3), also being of COMPLEX*8 floating point
precision.

An example of usage of the ccubsolv(a,z) routine can be found in the enclosed driver, ccubsolvdrv.f.

## Source files

**ccubsolv.f**
[2 kB]
Fortran 77 source for the ccubsolv(a,z) routine.

[ download |
view source ]

**ccubsolvdrv.f**
[1 kB]
Fortran 77 source for the driver of the ccubsolv(a,z) routine, illustrating
its use for the special case of

*c*_{0} = 1.23 - i1.44,
*c*_{1} = -2.18 + i3.97, and
*c*_{2} = 1.91 + i0.97.

Compile the Fortran-77 code for the driver using g77 [2]
and the enclosed Makefile.

[ download |
view source ]

**Makefile** [594 bytes]
The Makefile for compilation of the driver for the ccubsolv(a,z) routine.
To compile the source file into an executable, simply run 'make' in the
directory containing
ccubsolv.f and
ccubsolvdrv.f.

[ download |
view source ]

## References

[1]
For a description of the method of solving third-degree polynomial equations,
see Milton Abramowitz and Irene A. Stegun, *Handbook of mathematical
functions* (Dover, New York, 1972), ISBN 0-486-61272-4.
An online edition of this reference work is under way at the
NIST Digital Library of Mathematical
Functions project, hosted by the National
Institute of Standards and Technology.

[2] Documentation for the GNU Fortran 77 compiler, commonly denoted g77, is available online at http://gcc.gnu.org/onlinedocs/g77/.