Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input Detailed_Output Parameters Exceptions Files Particulars Examples Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

```   void rquad_c ( SpiceDouble  a,
SpiceDouble  b,
SpiceDouble  c,
SpiceDouble  root1,
SpiceDouble  root2 )

```

#### Abstract

```
Find the roots of a quadratic equation.
```

```
None.
```

```
MATH
POLYNOMIAL
ROOT

```

#### 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
ax   +   bx   +   c.
```

#### Detailed_Output

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

```
None.
```

#### Exceptions

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

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

/.
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 );

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, root1 );
printf ( "root2 is %f   %f\n", root2, root2 );

The printed results will be something like:

root1 is 0.000000000000000   1.000000000000000
root2 is 0.000000000000000   -1.000000000000000
```

#### Restrictions

```
No checks for overflow of the roots are performed.
```

```
None.
```

#### Author_and_Institution

```
N.J. Bachman   (JPL)
```

#### Version

```
-CSPICE Version 1.0.0, 13-JUN-1999 (NJB)
```

#### Index_Entries

```
`Wed Apr  5 17:54:42 2017`