\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.6479930097769547 \cdot 10^{+85}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -2.058574872602062 \cdot 10^{-105}:\\
\;\;\;\;-0.5 \cdot \frac{\frac{4 \cdot \left(c \cdot a\right)}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}{a}\\
\mathbf{elif}\;b \leq 1.6833943237704546 \cdot 10^{+136}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot 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.6479930097769547e+85)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -2.058574872602062e-105)
(*
-0.5
(/ (/ (* 4.0 (* c a)) (- b (sqrt (- (* b b) (* 4.0 (* c a)))))) a))
(if (<= b 1.6833943237704546e+136)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* 2.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.6479930097769547e+85) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -2.058574872602062e-105) {
tmp = -0.5 * (((4.0 * (c * a)) / (b - sqrt((b * b) - (4.0 * (c * a))))) / a);
} else if (b <= 1.6833943237704546e+136) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (2.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 | 33.8 |
|---|---|
| Target | 21.0 |
| Herbie | 9.1 |
if b < -2.64799300977695472e85Initial program 58.3
Simplified58.3
Taylor expanded around -inf 2.9
if -2.64799300977695472e85 < b < -2.058574872602062e-105Initial program 40.8
Simplified40.8
rmApplied flip-+_binary64_175740.8
Simplified15.4
if -2.058574872602062e-105 < b < 1.6833943237704546e136Initial program 11.8
if 1.6833943237704546e136 < b Initial program 56.4
Simplified56.4
Taylor expanded around inf 2.6
Simplified2.6
Final simplification9.1
herbie shell --seed 2020355
(FPCore (a b c)
:name "The quadratic formula (r2)"
: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)))