\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 -3.675391325498039 \cdot 10^{+126}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 6.382555368342549 \cdot 10^{-262}:\\
\;\;\;\;-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.1102892118009466 \cdot 10^{+81}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{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 -3.675391325498039e+126)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 6.382555368342549e-262)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.1102892118009466e+81)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(* -0.5 (/ (+ b b) 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 <= -3.675391325498039e+126) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 6.382555368342549e-262) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.1102892118009466e+81) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = -0.5 * ((b + b) / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.6 |
|---|---|
| Target | 20.2 |
| Herbie | 6.4 |
if b < -3.6753913254980387e126Initial program 60.8
Simplified60.8
Taylor expanded around -inf 1.7
if -3.6753913254980387e126 < b < 6.38255536834254894e-262Initial program 32.5
Simplified32.5
rmApplied flip-+_binary64_204332.5
Simplified16.2
rmApplied *-un-lft-identity_binary64_206916.2
Applied *-un-lft-identity_binary64_206916.2
Applied times-frac_binary64_207516.2
Applied times-frac_binary64_207516.2
Simplified16.2
Simplified9.0
if 6.38255536834254894e-262 < b < 1.11028921180094657e81Initial program 8.1
Simplified8.1
if 1.11028921180094657e81 < b Initial program 43.1
Simplified43.1
Taylor expanded around inf 3.8
Final simplification6.4
herbie shell --seed 2021042
(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)))