\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 -6.936942472764157 \cdot 10^{+83}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -1.2572184622052755 \cdot 10^{-278}:\\
\;\;\;\;-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 4.506449921036379 \cdot 10^{+122}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\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 -6.936942472764157e+83)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -1.2572184622052755e-278)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 4.506449921036379e+122)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) 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 <= -6.936942472764157e+83) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -1.2572184622052755e-278) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 4.506449921036379e+122) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / 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.2 |
|---|---|
| Target | 20.3 |
| Herbie | 6.9 |
if b < -6.93694247276415666e83Initial program 57.8
Simplified57.8
Taylor expanded around -inf 3.4
if -6.93694247276415666e83 < b < -1.25721846220527553e-278Initial program 32.0
Simplified31.9
rmApplied flip-+_binary64_39332.0
Simplified16.6
rmApplied *-un-lft-identity_binary64_41916.6
Applied *-un-lft-identity_binary64_41916.6
Applied times-frac_binary64_42516.6
Applied times-frac_binary64_42516.6
Simplified16.6
Simplified8.8
if -1.25721846220527553e-278 < b < 4.50644992103637885e122Initial program 9.4
Simplified9.4
if 4.50644992103637885e122 < b Initial program 52.3
Simplified52.4
Taylor expanded around inf 2.9
Simplified2.9
Final simplification6.9
herbie shell --seed 2020356
(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)))