\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.6404428421693406 \cdot 10^{+54}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -1.069698752870928 \cdot 10^{-294}:\\
\;\;\;\;-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 2.4425538060656697 \cdot 10^{+108}:\\
\;\;\;\;-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 -2.6404428421693406e+54)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -1.069698752870928e-294)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 2.4425538060656697e+108)
(* -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 <= -2.6404428421693406e+54) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -1.069698752870928e-294) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 2.4425538060656697e+108) {
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.7 |
|---|---|
| Target | 20.3 |
| Herbie | 6.7 |
if b < -2.6404428421693406e54Initial program 57.6
Simplified57.6
Taylor expanded around -inf 3.5
if -2.6404428421693406e54 < b < -1.06969875287092807e-294Initial program 29.4
Simplified29.4
rmApplied flip-+_binary6429.4
Simplified16.9
Simplified16.9
rmApplied *-un-lft-identity_binary6416.9
Applied *-un-lft-identity_binary6416.9
Applied times-frac_binary6416.9
Applied times-frac_binary6416.9
Simplified16.9
Simplified9.1
if -1.06969875287092807e-294 < b < 2.4425538060656697e108Initial program 8.8
Simplified8.8
rmApplied sub-neg_binary648.8
Simplified8.8
if 2.4425538060656697e108 < b Initial program 48.3
Simplified48.3
Taylor expanded around inf 3.8
Simplified3.8
Final simplification6.7
herbie shell --seed 2021205
(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)))