\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -2.7863758169125638 \cdot 10^{138}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -8.7810627886272542 \cdot 10^{-225}:\\
\;\;\;\;\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\
\mathbf{elif}\;b \le 1.74082702562304839 \cdot 10^{101}:\\
\;\;\;\;\frac{\frac{\left({b}^{2} - {b}^{2}\right) + 4 \cdot \left(a \cdot c\right)}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\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 VAR;
if ((b <= -2.7863758169125638e+138)) {
VAR = (1.0 * ((c / b) - (b / a)));
} else {
double VAR_1;
if ((b <= -8.781062788627254e-225)) {
VAR_1 = ((cbrt(1.0) * cbrt(1.0)) / ((2.0 * a) / (-b + sqrt(((b * b) - ((4.0 * a) * c))))));
} else {
double VAR_2;
if ((b <= 1.7408270256230484e+101)) {
VAR_2 = ((((pow(b, 2.0) - pow(b, 2.0)) + (4.0 * (a * c))) / (2.0 * a)) / (-b - sqrt(((b * b) - ((4.0 * a) * c)))));
} else {
VAR_2 = (-1.0 * (c / b));
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 20.9 |
| Herbie | 8.7 |
if b < -2.7863758169125638e+138Initial program 58.6
Taylor expanded around -inf 2.6
Simplified2.6
if -2.7863758169125638e+138 < b < -8.781062788627254e-225Initial program 6.7
rmApplied clear-num6.8
rmApplied add-cube-cbrt6.8
Applied associate-/l*6.8
Simplified6.8
if -8.781062788627254e-225 < b < 1.7408270256230484e+101Initial program 30.7
rmApplied clear-num30.7
rmApplied flip-+30.8
Applied associate-/r/30.9
Applied associate-/r*30.9
Simplified16.3
if 1.7408270256230484e+101 < b Initial program 60.0
Taylor expanded around inf 2.3
Final simplification8.7
herbie shell --seed 2020078
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))