Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
rquad

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Declarations
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version

Procedure

     RQUAD ( Roots of a quadratic equation )

     SUBROUTINE RQUAD (  A,  B,  C,  ROOT1,  ROOT2  )

Abstract

     Find the roots of a quadratic equation.

Required_Reading

     None.

Keywords

     MATH
     POLYNOMIAL
     ROOT

Declarations

     IMPLICIT NONE

     DOUBLE PRECISION      A
     DOUBLE PRECISION      B
     DOUBLE PRECISION      C
     DOUBLE PRECISION      ROOT1 ( 2 )
     DOUBLE PRECISION      ROOT2 ( 2 )

Brief_I/O

     VARIABLE  I/O  DESCRIPTION
     --------  ---  --------------------------------------------------
     A          I   Coefficient of quadratic term.
     B          I   Coefficient of linear term.
     C          I   Constant.
     ROOT1      O   Root built from positive discriminant term.
     ROOT2      O   Root built from negative discriminant term.

Detailed_Input

     A,
     B,
     C        are the coefficients of a quadratic polynomial

                      2
                 A * x   +  B * x  +  C.

Detailed_Output

     ROOT1,
     ROOT2    are the roots of the equation

                      2
                 A * x   +  B * x  +  C = 0.


              ROOT1 and ROOT2 are both arrays of length 2. The first
              element of each array is the real part of a root; the
              second element contains the complex part of the same
              root.

              When A is non-zero, ROOT1 represents the root

                               _____________
                              /  2
                 - B   +    \/  B    -   4AC
                 ---------------------------
                               2A


              and ROOT2 represents the root

                               _____________
                              /  2
                 - B   -    \/  B    -   4AC
                 --------------------------- .
                               2A


              When A is zero and B is non-zero, ROOT1 and ROOT2 both
              represent the root

                 - C / B.

Parameters

     None.

Exceptions

     1)  If the input coefficients A and B are both zero, the error
         SPICE(DEGENERATECASE) is signaled. The output arguments
         are not modified.

Files

     None.

Particulars

     None.

Examples

     1)   Humor us and suppose we want to compute the "golden ratio."

          The quantity r is defined by the equation

             1/r = r/(1-r),

          which is equivalent to

              2
             r   +  r  -  1  =  0.

          The following code fragment does the job.


             C
             C     Compute "golden ratio." The root we want,
             C
             C                ___
             C               /
             C        -1 + \/  5
             C        -----------,
             C             2
             C
             C
             C     is contained in ROOT1.
             C

                   CALL RQUAD ( 1.D0, 1.D0, -1.D0, ROOT1, ROOT2 )

                   PRINT *, 'The "golden ratio" is ', ROOT1(1)


     2)   The equation,

              2
             x   +  1  =  0

          can be solved by the code fragment


             C
             C     Let's do one with imaginary roots just for fun.
             C

                   CALL RQUAD ( 1.D0,  0.D0,  1.D0,  ROOT1,  ROOT2 )

                   PRINT *, 'ROOT1 is ', ROOT1
                   PRINT *, 'ROOT2 is ', ROOT2

          The printed results will be something like:


             ROOT1 is 0.000000000000000    1.000000000000000
             ROOT2 is 0.000000000000000   -1.000000000000000

Restrictions

     1)  No checks for overflow of the roots are performed.

Literature_References

     None.

Author_and_Institution

     N.J. Bachman       (JPL)
     J. Diaz del Rio    (ODC Space)
     W.L. Taber         (JPL)

Version

    SPICELIB Version 1.1.0, 17-JUN-2021 (JDR)

        Added IMPLICIT NONE statement.

        Edited the header to comply with NAIF standard.

    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)

        Comment section for permuted index source lines was added
        following the header.

    SPICELIB Version 1.0.0, 10-JUL-1990 (NJB)
Fri Dec 31 18:36:44 2021