\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.632227499857312 \cdot 10^{+135}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 6.5744603722298956 \cdot 10^{-217}:\\
\;\;\;\;-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 7.357075075270595 \cdot 10^{+109}:\\
\;\;\;\;-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 -6.632227499857312e+135)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 6.5744603722298956e-217)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 7.357075075270595e+109)
(* -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 <= -6.632227499857312e+135) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 6.5744603722298956e-217) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 7.357075075270595e+109) {
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 | 33.9 |
|---|---|
| Target | 20.9 |
| Herbie | 6.7 |
if b < -6.6322274998573121e135Initial program 61.9
Simplified61.9
Taylor expanded around -inf 1.6
if -6.6322274998573121e135 < b < 6.57446037222989558e-217Initial program 31.7
Simplified31.7
rmApplied flip-+_binary64_107531.8
Simplified16.7
rmApplied *-un-lft-identity_binary64_110116.7
Applied *-un-lft-identity_binary64_110116.7
Applied times-frac_binary64_110716.8
Applied times-frac_binary64_110716.8
Simplified16.8
Simplified9.9
rmApplied *-un-lft-identity_binary64_11019.9
Applied associate-/r*_binary64_10459.9
if 6.57446037222989558e-217 < b < 7.3570750752705946e109Initial program 7.2
Simplified7.2
if 7.3570750752705946e109 < b Initial program 49.3
Simplified49.3
Taylor expanded around inf 4.0
Final simplification6.7
herbie shell --seed 2021076
(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)))