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
cspice_rquad

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_RQUAD finds the roots of a quadratic equation.

I/O


   Given:

      a,
      b,
      c        the coefficients of a quadratic polynomial

                       2
                  a * x   +  b * x  +  c.

               help, a
                  DOUBLE = Scalar
               help, b
                  DOUBLE = Scalar
               help, c
                  DOUBLE = Scalar

   the call:

      cspice_rquad, a, b, c, root1, root2

   returns:

      root1,
      root2    the roots of the equation

                       2
                  a * x   +  b * x  +  c = 0.

               help, root1
                  DOUBLE = Array[2]
               help, root2
                  DOUBLE = Array[2]


               `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.

Examples


   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) Calculate the roots of the following quadratic equation:

          2
         x  + 2x + 3 = 0

      Example code begins here.


      PRO rquad_ex1

         cspice_rquad, 1.d, 2.d, 3.d, root1, root2
         print, 'Solutions using SPICE:'
         print, FORMAT='("   Root #1:", 2F12.7)', root1
         print, FORMAT='("   Root #2:", 2F12.7)', root2

         ;;
         ;; Check the IDL function.
         ;;
         roots = fz_roots([3,2,1])
         print, 'Solutions using IDL native code:'
         print, FORMAT='("   Root #1:", 2F12.7)', roots(0)
         print, FORMAT='("   Root #2:", 2F12.7)', roots(1)

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      Solutions using SPICE:
         Root #1:  -1.0000000   1.4142136
         Root #2:  -1.0000000  -1.4142136
      Solutions using IDL native code:
         Root #1:  -1.0000000  -1.4142134
         Root #2:  -1.0000000   1.4142134


Particulars


   None.

Exceptions


   1)  If the input coefficients `a' and `b' are both zero, the error
       SPICE(DEGENERATECASE) is signaled by a routine in the call
       tree of this routine. The output arguments are not modified.

   2)  If any of the input arguments, `a', `b' or `c', is undefined,
       an error is signaled by the IDL error handling system.

   3)  If any of the input arguments, `a', `b' or `c', is not of the
       expected type, or it does not have the expected dimensions and
       size, an error is signaled by the Icy interface.

   4)  If any of the output arguments, `root1' or `root2', is not a
       named variable, an error is signaled by the Icy interface.

Files


   None.

Restrictions


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

Required_Reading


   ICY.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.1, 17-JUN-2021 (JDR)

       Edited the header to comply with NAIF standard. Added example's
       problem statement and reformatted example's output.

       Added -Parameters, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections.

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   roots of a quadratic equation



Fri Dec 31 18:43:07 2021