\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 -9.78240408384728 \cdot 10^{+119}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2.0018226176283294 \cdot 10^{-297}:\\
\;\;\;\;-0.5 \cdot \frac{1}{\frac{\frac{1}{c}}{4} \cdot \left(b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right)}\\
\mathbf{elif}\;b \leq 2.79442743178515 \cdot 10^{+92}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}{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 -9.78240408384728e+119)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 2.0018226176283294e-297)
(*
-0.5
(/ 1.0 (* (/ (/ 1.0 c) 4.0) (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 2.79442743178515e+92)
(* -0.5 (/ (+ b (sqrt (+ (* b b) (* c (* a -4.0))))) 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 <= -9.78240408384728e+119) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 2.0018226176283294e-297) {
tmp = -0.5 * (1.0 / (((1.0 / c) / 4.0) * (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 2.79442743178515e+92) {
tmp = -0.5 * ((b + sqrt((b * b) + (c * (a * -4.0)))) / 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 | 33.8 |
|---|---|
| Target | 20.9 |
| Herbie | 6.9 |
if b < -9.7824040838472795e119Initial program 60.8
Simplified60.8
Taylor expanded around -inf 2.2
if -9.7824040838472795e119 < b < 2.001822617628329e-297Initial program 32.2
Simplified32.2
rmApplied clear-num_binary6432.2
Simplified32.2
rmApplied flip-+_binary6432.3
Simplified16.3
rmApplied associate-/r/_binary6415.2
Simplified9.3
if 2.001822617628329e-297 < b < 2.7944274317851502e92Initial program 8.9
Simplified9.0
rmApplied sub-neg_binary649.0
Simplified9.0
if 2.7944274317851502e92 < b Initial program 45.6
Simplified45.6
Taylor expanded around inf 4.4
Simplified4.4
Final simplification6.9
herbie shell --seed 2021198
(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)))