void rquad_c ( SpiceDouble a,
SpiceDouble b,
SpiceDouble c,
SpiceDouble root1[2],
SpiceDouble root2[2] )
Find the roots of a quadratic equation.
None.
MATH
POLYNOMIAL
ROOT
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.
a,
b,
c are the coefficients of a quadratic polynomial
2
ax + bx + c.
root1,
root2 are the roots of the equation,
2
ax + bx + 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 nonzero, 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 nonzero, root1 and root2
both represent the root
 c / b.
None.
1) If the input coefficients a and b are both zero, the error
SPICE(DEGENERATECASE) is signalled. The output arguments
are not modified.
None.
None.
1) Humor us and suppose we want to compute the "golden ratio."
The quantity r is defined by the equation
1/r = r/(1r),
which is equivalent to
2
r + r  1 = 0.
The following code fragment does the job.
/.
Compute "golden ratio." The root we want,
___
/
1 + \/ 5
,
2
is contained in root1.
./
rquad_c ( 1., 1., 1., root1, root2 );
printf ( "The \"golden ratio\" is %f\n", root1[0] );
2) The equation,
2
x + 1 = 0
can be solved by the code fragment
/.
Let's do one with imaginary roots just for fun.
./
rquad_c ( 1., 0., 1., root1, root2 );
printf ( "root1 is %f %f\n", root1[0], root1[1] );
printf ( "root2 is %f %f\n", root2[0], root2[1] );
The printed results will be something like:
root1 is 0.000000000000000 1.000000000000000
root2 is 0.000000000000000 1.000000000000000
No checks for overflow of the roots are performed.
None.
N.J. Bachman (JPL)
CSPICE Version 1.0.0, 13JUN1999 (NJB)
roots of a quadratic equation
