\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -2.5636004990570266 \cdot 10^{-52}:\\
\;\;\;\;-0.5 \cdot \left(-0.5 \cdot \frac{c \cdot -4}{b}\right)\\
\mathbf{elif}\;b \leq 8.470534450340484 \cdot 10^{+97}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{c \cdot \left(-4 \cdot a\right) + b \cdot b}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b \cdot 2}{a}\\
\end{array}
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(if (<= b -2.5636004990570266e-52)
(* -0.5 (* -0.5 (/ (* c -4.0) b)))
(if (<= b 8.470534450340484e+97)
(* -0.5 (/ (+ b (sqrt (+ (* c (* -4.0 a)) (* b b)))) a))
(* -0.5 (/ (* b 2.0) a)))))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 tmp;
if (b <= -2.5636004990570266e-52) {
tmp = -0.5 * (-0.5 * ((c * -4.0) / b));
} else if (b <= 8.470534450340484e+97) {
tmp = -0.5 * ((b + sqrt((c * (-4.0 * a)) + (b * b))) / a);
} else {
tmp = -0.5 * ((b * 2.0) / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 21.0 |
| Herbie | 10.2 |
if b < -2.5636004990570266e-52Initial program 54.0
Simplified54.0
rmApplied clear-num_binary6454.0
Simplified47.8
Taylor expanded around -inf 39.1
Simplified7.9
if -2.5636004990570266e-52 < b < 8.47053445034048353e97Initial program 14.0
Simplified14.0
rmApplied fma-udef_binary6414.0
Simplified14.0
if 8.47053445034048353e97 < b Initial program 47.2
Simplified47.2
Taylor expanded around inf 4.4
Simplified4.4
Final simplification10.2
herbie shell --seed 2021210
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))