\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -6.38219880313288259 \cdot 10^{149}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 2.7444235711350233 \cdot 10^{-95}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\mathbf{elif}\;b \le 5.78921681038671 \cdot 10^{118}:\\
\;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\end{array}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 temp;
if ((b <= -6.382198803132883e+149)) {
temp = (-1.0 * (c / b));
} else {
double temp_1;
if ((b <= 2.7444235711350233e-95)) {
temp_1 = ((2.0 * c) / (-b + sqrt(((b * b) - (4.0 * (a * c))))));
} else {
double temp_2;
if ((b <= 5.78921681038671e+118)) {
temp_2 = ((1.0 / (2.0 * a)) * (-b - sqrt(((b * b) - (4.0 * (a * c))))));
} else {
temp_2 = (-1.0 * (b / a));
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.7 |
|---|---|
| Target | 20.6 |
| Herbie | 7.2 |
if b < -6.382198803132883e+149Initial program 63.6
Taylor expanded around -inf 1.4
if -6.382198803132883e+149 < b < 2.7444235711350233e-95Initial program 28.4
rmApplied clear-num28.5
rmApplied flip--30.3
Applied associate-/r/30.3
Applied associate-/r*30.3
Simplified15.6
Taylor expanded around 0 11.0
if 2.7444235711350233e-95 < b < 5.78921681038671e+118Initial program 5.2
rmApplied clear-num5.4
rmApplied div-inv5.5
Applied add-cube-cbrt5.5
Applied times-frac5.5
Simplified5.5
Simplified5.4
if 5.78921681038671e+118 < b Initial program 51.7
rmApplied clear-num51.7
Taylor expanded around 0 2.5
Final simplification7.2
herbie shell --seed 2020066
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))