\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 -3.6190188158506807 \cdot 10^{149}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 2.7444235711350233 \cdot 10^{-95}:\\
\;\;\;\;\left(2 \cdot c\right) \cdot \frac{1}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\mathbf{elif}\;b \le 5.78921681038671 \cdot 10^{118}:\\
\;\;\;\;\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}\\
\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 <= -3.6190188158506807e+149)) {
temp = (-1.0 * (c / b));
} else {
double temp_1;
if ((b <= 2.7444235711350233e-95)) {
temp_1 = ((2.0 * c) * (1.0 / (-b + sqrt(((b * b) - (4.0 * (a * c)))))));
} else {
double temp_2;
if ((b <= 5.78921681038671e+118)) {
temp_2 = ((-b - sqrt(((b * b) - (4.0 * (a * c))))) * (1.0 / (2.0 * a)));
} 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 < -3.6190188158506807e+149Initial program 63.6
Taylor expanded around -inf 1.4
if -3.6190188158506807e+149 < b < 2.7444235711350233e-95Initial program 28.4
rmApplied clear-num28.5
rmApplied flip--30.3
Applied associate-/r/30.3
Applied add-sqr-sqrt30.3
Applied times-frac30.3
Simplified15.7
Simplified15.7
Taylor expanded around 0 11.2
if 2.7444235711350233e-95 < b < 5.78921681038671e+118Initial program 5.2
rmApplied div-inv5.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 "The quadratic formula (r2)"
: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)))