\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 -8.57596628546545472 \cdot 10^{75}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le -3.5042457694696975 \cdot 10^{-155}:\\
\;\;\;\;\frac{\frac{\left({b}^{2} - {b}^{2}\right) + 4 \cdot \left(a \cdot c\right)}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}}{2 \cdot a}\\
\mathbf{elif}\;b \le 1.1044936555910329 \cdot 10^{30}:\\
\;\;\;\;\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 \left(\frac{c}{b} - \frac{b}{a}\right)\\
\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 <= -8.575966285465455e+75)) {
VAR = (-1.0 * (c / b));
} else {
double VAR_1;
if ((b <= -3.5042457694696975e-155)) {
VAR_1 = ((((pow(b, 2.0) - pow(b, 2.0)) + (4.0 * (a * c))) / (sqrt(((b * b) - (4.0 * (a * c)))) - b)) / (2.0 * a));
} else {
double VAR_2;
if ((b <= 1.1044936555910329e+30)) {
VAR_2 = ((-b - sqrt(((b * b) - (4.0 * (a * c))))) * (1.0 / (2.0 * a)));
} else {
VAR_2 = (1.0 * ((c / b) - (b / a)));
}
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 | 21.5 |
| Herbie | 9.3 |
if b < -8.575966285465455e+75Initial program 58.5
Taylor expanded around -inf 2.8
if -8.575966285465455e+75 < b < -3.5042457694696975e-155Initial program 39.7
rmApplied flip--39.7
Simplified17.8
Simplified17.8
if -3.5042457694696975e-155 < b < 1.1044936555910329e+30Initial program 12.1
rmApplied div-inv12.3
if 1.1044936555910329e+30 < b Initial program 34.9
Taylor expanded around inf 5.9
Simplified5.9
Final simplification9.3
herbie shell --seed 2020102
(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)))