\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 -3.4633822406296006 \cdot 10^{+113}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -2.535008326067869 \cdot 10^{-289}:\\
\;\;\;\;-0.5 \cdot \frac{\frac{4 \cdot \left(c \cdot a\right)}{a}}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\
\mathbf{elif}\;b \leq 3.0185045942898314 \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 \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 -3.4633822406296006e+113)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -2.535008326067869e-289)
(*
-0.5
(/ (/ (* 4.0 (* c a)) a) (- b (sqrt (- (* b b) (* 4.0 (* c a)))))))
(if (<= b 3.0185045942898314e+49)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) 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 <= -3.4633822406296006e+113) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -2.535008326067869e-289) {
tmp = -0.5 * (((4.0 * (c * a)) / a) / (b - sqrt((b * b) - (4.0 * (c * a)))));
} else if (b <= 3.0185045942898314e+49) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / 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.9 |
|---|---|
| Target | 21.0 |
| Herbie | 8.8 |
if b < -3.4633822406296006e113Initial program 60.7
Simplified60.7
Taylor expanded around -inf 1.8
if -3.4633822406296006e113 < b < -2.5350083260678689e-289Initial program 33.3
Simplified33.3
rmApplied clear-num_binary64_75933.4
rmApplied flip-+_binary64_73433.4
Applied associate-/r/_binary64_70633.4
Applied associate-/r*_binary64_70433.5
Simplified14.9
if -2.5350083260678689e-289 < b < 3.01850459428983145e49Initial program 10.1
Simplified10.1
if 3.01850459428983145e49 < b Initial program 37.0
Simplified37.0
Taylor expanded around inf 5.7
Simplified5.7
Final simplification8.8
herbie shell --seed 2021045
(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)))