\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 -7912379577645.802:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -7.525896497608905 \cdot 10^{-142}:\\
\;\;\;\;-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 6.526889854778783 \cdot 10^{+49}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\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 -7912379577645.802)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -7.525896497608905e-142)
(*
-0.5
(/ (/ (* 4.0 (* c a)) (- b (sqrt (- (* b b) (* 4.0 (* c a)))))) a))
(if (<= b 6.526889854778783e+49)
(* -0.5 (/ (+ b (sqrt (+ (* b b) (* a (* c -4.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 <= -7912379577645.802) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -7.525896497608905e-142) {
tmp = -0.5 * (((4.0 * (c * a)) / (b - sqrt((b * b) - (4.0 * (c * a))))) / a);
} else if (b <= 6.526889854778783e+49) {
tmp = -0.5 * ((b + sqrt((b * b) + (a * (c * -4.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 | 20.9 |
| Herbie | 8.9 |
if b < -7912379577645.80176Initial program 56.3
Simplified56.3
Taylor expanded around -inf 4.9
if -7912379577645.80176 < b < -7.5258964976089047e-142Initial program 34.5
Simplified34.5
rmApplied flip-+_binary6434.5
Simplified17.1
if -7.5258964976089047e-142 < b < 6.5268898547787833e49Initial program 11.6
Simplified11.6
rmApplied sub-neg_binary6411.6
Simplified11.6
if 6.5268898547787833e49 < b Initial program 38.7
Simplified38.7
Taylor expanded around inf 5.2
Simplified5.2
Final simplification8.9
herbie shell --seed 2020219
(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)))