CSPICE_RQUAD calculates the roots of a quadratic equation.
For important details concerning this module's function, please refer to
the CSPICE routine rquad_c.
Given the coefficients of a quadratic equation, 'a', 'b', 'c',
ax + bx + c = 0
cspice_rquad, a, b, c, root1, root2
returns a double precision 2-vector to variable 'root1'
representing the first complex root of the equation, and a
second double precision vector to variable 'root2' representing
the second root.
The returned 2-vectors represent complex numbers of the
form root = a + bi. root holds the real component of the
root, the root holds the imaginary component.
IDL native code to perform the same computation:
root = fz_root( [c ,b, a] )
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.
;; Solve x + 2x + 3 = 0
cspice_rquad, 1.d, 2.d, 3.d, root1, root2
IDL outputs for root1:
IDL outputs for root2:
;; Check the IDL function.
( -1.00000, -1.41421)( -1.00000, 1.41421)
Note the ordering of the roots differs between cspice_rquad
-Icy Version 1.0.0, 16-JUN-2003, EDW (JPL)
roots of a quadratic equation