next up previous index
Next: C208 Roots of Up: CERNLIB Previous: C205 Zero of

C207 Roots of a Cubic Equation

Routine ID: C207
Author(s): K.S. KölbigLibrary: MATHLIB
Submitter: Submitted: 15.01.1988
Language: FortranRevised: 01.12.1994

Subroutine subprograms RRTEQ3 and DRTEQ3 compute the three roots of

x3+ rx2+ sx + t = 0 (*)

for real coefficients r, s, t.

On computers other than CDC or Cray, only the double-precision version DRTEQ3 is available. On CDC and Cray computers, only the single-precision version RRTEQ3 is available.

Structure:

SUBROUTINE subprograms
User Entry Names: RRTEQ3, DRTEQ3
Obsolete User Entry Names: RTEQ3 RRTEQ3

Usage:

For t=R (type REAL), t=D (type DOUBLE PRECISION),

    CALL tRTEQ3(R,S,T,X,D)
R,S,T
(type according to t) Coefficients r,s,t in (*) .
X
(type according to t) One-dimensional array of length ≥3 . On exit, X is set as described below.
D
(type according to t) On exit, D is set to the value of the discriminant of (*) :
> 0: One real root X(1) and two complex conjugate roots X(2)+iX(3) , X(2)-iX(3) ;
= 0: Three real roots X(1), X(2), X(3), where at least X(2)= X(3) ;
< 0: Three distinct real roots X(1), X(2), X(3).

Method:

The classical method of Tartaglia-Vieta is used. In certain cases, the solutions are improved by Newton iteration.

Accuracy:

Depends on the coefficients r,s,t. The values of X(1), X(2), X(3) and of D may be inaccurate if |D| is very small, even in the case of ``exact'' coefficients.

C208


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995