\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.2147252142309174 \cdot 10^{+151}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 7.387487850441641 \cdot 10^{-119}:\\
\;\;\;\;-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.6892606184473783 \cdot 10^{+72}:\\
\;\;\;\;-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} - 2 \cdot \frac{c}{b}\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.2147252142309174e+151)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 7.387487850441641e-119)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 2.6892606184473783e+72)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(* -0.5 (- (* 2.0 (/ b a)) (* 2.0 (/ 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 <= -1.2147252142309174e+151) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 7.387487850441641e-119) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 2.6892606184473783e+72) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = -0.5 * ((2.0 * (b / a)) - (2.0 * (c / b)));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.1 |
|---|---|
| Target | 21.1 |
| Herbie | 7.2 |
if b < -1.2147252142309174e151Initial program 63.7
Simplified63.7
rmApplied flip-+_binary64_73463.7
Simplified38.6
rmApplied div-inv_binary64_75738.6
Applied associate-/l*_binary64_70538.6
Simplified38.6
Taylor expanded around -inf 2.1
if -1.2147252142309174e151 < b < 7.3874878504416411e-119Initial program 29.5
Simplified29.5
rmApplied flip-+_binary64_73430.6
Simplified16.6
rmApplied *-un-lft-identity_binary64_76016.6
Applied *-un-lft-identity_binary64_76016.6
Applied times-frac_binary64_76616.6
Applied times-frac_binary64_76616.6
Simplified16.6
Simplified10.5
if 7.3874878504416411e-119 < b < 2.68926061844737826e72Initial program 6.1
Simplified6.1
if 2.68926061844737826e72 < b Initial program 42.1
Simplified42.1
Taylor expanded around inf 4.7
Final simplification7.2
herbie shell --seed 2021098
(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)))