\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.0628887340948368 \cdot 10^{-15}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq -2.5936672057451206 \cdot 10^{-222}:\\
\;\;\;\;-0.5 \cdot \frac{\frac{4}{\frac{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{c \cdot a}}}{a}\\
\mathbf{elif}\;b \leq 5.559837845063527 \cdot 10^{+97}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a}\\
\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 -1.0628887340948368e-15)
(- (/ c b))
(if (<= b -2.5936672057451206e-222)
(*
-0.5
(/ (/ 4.0 (/ (- b (sqrt (- (* b b) (* 4.0 (* c a))))) (* c a))) a))
(if (<= b 5.559837845063527e+97)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(- (/ 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 <= -1.0628887340948368e-15) {
tmp = -(c / b);
} else if (b <= -2.5936672057451206e-222) {
tmp = -0.5 * ((4.0 / ((b - sqrt((b * b) - (4.0 * (c * a)))) / (c * a))) / a);
} else if (b <= 5.559837845063527e+97) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.6 |
|---|---|
| Target | 21.3 |
| Herbie | 9.6 |
if b < -1.06288873409483677e-15Initial program 55.5
Simplified55.5
Taylor expanded around -inf 6.1
Simplified6.1
if -1.06288873409483677e-15 < b < -2.59366720574512058e-222Initial program 29.3
Simplified29.3
rmApplied flip-+_binary64_73429.3
Simplified19.7
rmApplied associate-/l*_binary64_70519.8
if -2.59366720574512058e-222 < b < 5.5598378450635267e97Initial program 10.9
Simplified10.9
if 5.5598378450635267e97 < b Initial program 47.6
Simplified47.7
Taylor expanded around inf 4.3
Final simplification9.6
herbie shell --seed 2021044
(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)))