\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -4.6537017569063518 \cdot 10^{-82}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 1.0479007947857462 \cdot 10^{99}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(2 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}\right)\\
\end{array}double code(double a, double b, double c) {
return ((-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a));
}
double code(double a, double b, double c) {
double temp;
if ((b <= -4.653701756906352e-82)) {
temp = (-1.0 * (c / b));
} else {
double temp_1;
if ((b <= 1.0479007947857462e+99)) {
temp_1 = ((1.0 / 2.0) * ((-b - sqrt(((b * b) - (4.0 * (a * c))))) / a));
} else {
temp_1 = ((1.0 / 2.0) * ((2.0 * (c / b)) - (2.0 * (b / a))));
}
temp = temp_1;
}
return temp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.7 |
|---|---|
| Target | 21.3 |
| Herbie | 10.3 |
if b < -4.653701756906352e-82Initial program 52.8
Taylor expanded around -inf 9.2
if -4.653701756906352e-82 < b < 1.0479007947857462e+99Initial program 13.5
rmApplied clear-num13.6
rmApplied *-un-lft-identity13.6
Applied times-frac13.6
Applied add-cube-cbrt13.6
Applied times-frac13.6
Simplified13.6
Simplified13.5
if 1.0479007947857462e+99 < b Initial program 47.7
rmApplied clear-num47.7
rmApplied *-un-lft-identity47.7
Applied times-frac47.7
Applied add-cube-cbrt47.7
Applied times-frac47.7
Simplified47.7
Simplified47.6
Taylor expanded around inf 4.2
Final simplification10.3
herbie shell --seed 2020065 +o rules:numerics
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))