\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 -4.848123900391362 \cdot 10^{-140}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq 9.052048006936924 \cdot 10^{+27}:\\
\;\;\;\;\frac{-\left(b + \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -4\right)}, b\right)\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\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 -4.848123900391362e-140)
(- (/ c b))
(if (<= b 9.052048006936924e+27)
(/ (- (+ b (hypot (sqrt (* c (* a -4.0))) b))) (* a 2.0))
(- (/ c b) (/ 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 <= -4.848123900391362e-140) {
tmp = -(c / b);
} else if (b <= 9.052048006936924e+27) {
tmp = -(b + hypot(sqrt(c * (a * -4.0)), b)) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 21.0 |
| Herbie | 12.3 |
if b < -4.84812390039136203e-140Initial program 50.1
Taylor expanded in b around -inf 12.0
if -4.84812390039136203e-140 < b < 9.05204800693692385e27Initial program 12.9
Applied neg-sub0_binary6412.9
Applied associate--l-_binary6412.9
Simplified16.5
if 9.05204800693692385e27 < b Initial program 35.8
Taylor expanded in b around inf 6.4
Final simplification12.3
herbie shell --seed 2021275
(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)))