\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 -2.986384134100874 \cdot 10^{+125}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \leq -1.9251932428213444 \cdot 10^{-304}:\\
\;\;\;\;-0.5 \cdot \frac{4}{\frac{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{c}}\\
\mathbf{elif}\;b \leq 3.346781742900937 \cdot 10^{+117}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b + 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 -2.986384134100874e+125)
(- (/ c b))
(if (<= b -1.9251932428213444e-304)
(* -0.5 (/ 4.0 (/ (- b (sqrt (- (* b b) (* 4.0 (* c a))))) c)))
(if (<= b 3.346781742900937e+117)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(* -0.5 (/ (+ 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 <= -2.986384134100874e+125) {
tmp = -(c / b);
} else if (b <= -1.9251932428213444e-304) {
tmp = -0.5 * (4.0 / ((b - sqrt((b * b) - (4.0 * (c * a)))) / c));
} else if (b <= 3.346781742900937e+117) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (a * 2.0);
} else {
tmp = -0.5 * ((b + b) / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.6 |
|---|---|
| Target | 20.0 |
| Herbie | 6.5 |
if b < -2.9863841341008739e125Initial program 60.9
Simplified60.9
Taylor expanded around -inf 2.1
Taylor expanded around 0 2.1
Simplified2.1
if -2.9863841341008739e125 < b < -1.9251932428213444e-304Initial program 33.1
Simplified33.1
rmApplied flip-+_binary64_73433.1
Simplified15.3
rmApplied *-un-lft-identity_binary64_76015.3
Applied *-un-lft-identity_binary64_76015.3
Applied times-frac_binary64_76615.3
Simplified15.3
Simplified7.6
rmApplied associate-/r*_binary64_7047.6
Simplified7.6
if -1.9251932428213444e-304 < b < 3.3467817429009369e117Initial program 9.1
if 3.3467817429009369e117 < b Initial program 52.0
Simplified52.1
Taylor expanded around inf 3.8
Final simplification6.5
herbie shell --seed 2021032
(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)))