\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.888382392154385 \cdot 10^{+67}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -2.1112118607264023 \cdot 10^{-305}:\\
\;\;\;\;-0.5 \cdot \left(4 \cdot \frac{c}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\right)\\
\mathbf{elif}\;b \leq 1.2667031361491607 \cdot 10^{+67}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \left(\frac{b}{a} - \frac{c}{b}\right)\right)\\
\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.888382392154385e+67)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -2.1112118607264023e-305)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.2667031361491607e+67)
(* -0.5 (/ (+ b (sqrt (+ (* b b) (* a (* c -4.0))))) a))
(* -0.5 (* 2.0 (- (/ b a) (/ c b))))))))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.888382392154385e+67) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -2.1112118607264023e-305) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.2667031361491607e+67) {
tmp = -0.5 * ((b + sqrt((b * b) + (a * (c * -4.0)))) / a);
} else {
tmp = -0.5 * (2.0 * ((b / a) - (c / b)));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.2 |
|---|---|
| Target | 20.8 |
| Herbie | 6.9 |
if b < -2.8883823921543848e67Initial program 57.7
Simplified57.7
Taylor expanded around -inf 3.5
if -2.8883823921543848e67 < b < -2.11121186072640234e-305Initial program 30.0
Simplified30.0
rmApplied flip-+_binary6430.0
Simplified17.1
rmApplied *-un-lft-identity_binary6417.1
Applied *-un-lft-identity_binary6417.1
Applied times-frac_binary6417.1
Applied times-frac_binary6417.1
Simplified17.1
Simplified9.6
if -2.11121186072640234e-305 < b < 1.2667031361491607e67Initial program 9.4
Simplified9.4
rmApplied sub-neg_binary649.4
Simplified9.4
if 1.2667031361491607e67 < b Initial program 39.0
Simplified39.0
Taylor expanded around inf 4.8
Simplified4.8
Final simplification6.9
herbie shell --seed 2020260
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected #f
: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)))