\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.9235974648770365 \cdot 10^{+88}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 4.9581933950094135 \cdot 10^{-195}:\\
\;\;\;\;-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.70585956042705 \cdot 10^{+98}:\\
\;\;\;\;-0.5 \cdot \frac{1}{\frac{a}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}\\
\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 -3.9235974648770365e+88)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 4.9581933950094135e-195)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 2.70585956042705e+98)
(* -0.5 (/ 1.0 (/ a (+ b (sqrt (- (* b b) (* 4.0 (* c 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 <= -3.9235974648770365e+88) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 4.9581933950094135e-195) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 2.70585956042705e+98) {
tmp = -0.5 * (1.0 / (a / (b + sqrt((b * b) - (4.0 * (c * 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.7 |
|---|---|
| Target | 20.2 |
| Herbie | 6.7 |
if b < -3.92359746487703648e88Initial program 58.2
Simplified58.2
Taylor expanded around -inf 3.2
if -3.92359746487703648e88 < b < 4.9581933950094135e-195Initial program 29.0
Simplified29.0
rmApplied flip-+_binary6429.1
Simplified16.0
rmApplied *-un-lft-identity_binary6416.0
Applied *-un-lft-identity_binary6416.0
Applied times-frac_binary6416.0
Applied times-frac_binary6416.0
Simplified16.0
Simplified9.9
if 4.9581933950094135e-195 < b < 2.70585956042705002e98Initial program 6.9
Simplified6.9
rmApplied clear-num_binary647.1
if 2.70585956042705002e98 < b Initial program 45.2
Simplified45.2
Taylor expanded around inf 4.1
Simplified4.1
Final simplification6.7
herbie shell --seed 2020233
(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)))