\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 -1.6066190304518379 \cdot 10^{+153}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 3.53250645588002 \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.3266789206923356 \cdot 10^{+49}:\\
\;\;\;\;-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 \frac{b}{a}\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 -1.6066190304518379e+153)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 3.53250645588002e-262)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.3266789206923356e+49)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(* -0.5 (* 2.0 (/ 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 <= -1.6066190304518379e+153) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 3.53250645588002e-262) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.3266789206923356e+49) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = -0.5 * (2.0 * (b / a));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.7 |
|---|---|
| Target | 21.3 |
| Herbie | 6.7 |
if b < -1.6066190304518379e153Initial program 63.9
Simplified63.9
Taylor expanded around -inf 1.3
if -1.6066190304518379e153 < b < 3.5325064558800199e-262Initial program 33.7
Simplified33.7
rmApplied flip-+_binary64_5233.8
Simplified16.8
rmApplied *-un-lft-identity_binary64_7816.8
Applied *-un-lft-identity_binary64_7816.8
Applied times-frac_binary64_8416.8
Applied times-frac_binary64_8416.8
Simplified16.8
Simplified8.7
if 3.5325064558800199e-262 < b < 1.3266789206923356e49Initial program 8.9
Simplified8.8
if 1.3266789206923356e49 < b Initial program 39.2
Simplified39.3
rmApplied flip-+_binary64_5261.7
Simplified61.0
Taylor expanded around 0 5.2
Final simplification6.7
herbie shell --seed 2020354
(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)))