Search:

ccubsolv.f

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

z3 + c2 z2 + c1 z + c0 = 0,

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

A(1) = c0,    A(2) = c1,    A(3) = c2,

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

c0 = 1.23 - i1.44,    c1 = -2.18 + i3.97,    and    c2 = 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/.

Return to previous page

Leave a message

Your name:

Your email: (required)

Message:

Generated by ::emailform::

Last modified Wednesday 15 Feb 2023