\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 -1.5993207442876947 \cdot 10^{-91}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le -6.3130237661631722 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{1}{2} \cdot \left(\left({b}^{2} - {b}^{2}\right) + 4 \cdot \left(a \cdot c\right)\right)}{a} \cdot \frac{1}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\mathbf{elif}\;b \le -9.09785312290987894 \cdot 10^{-156}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 3.9701546350182474 \cdot 10^{129}:\\
\;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\
\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 <= -1.5993207442876947e-91)) {
VAR = (-1.0 * (c / b));
} else {
double VAR_1;
if ((b <= -6.313023766163172e-125)) {
VAR_1 = ((((1.0 / 2.0) * ((pow(b, 2.0) - pow(b, 2.0)) + (4.0 * (a * c)))) / a) * (1.0 / (-b + sqrt(((b * b) - (4.0 * (a * c)))))));
} else {
double VAR_2;
if ((b <= -9.097853122909879e-156)) {
VAR_2 = (-1.0 * (c / b));
} else {
double VAR_3;
if ((b <= 3.9701546350182474e+129)) {
VAR_3 = (1.0 / ((2.0 * a) / (-b - sqrt(((b * b) - (4.0 * (a * c)))))));
} else {
VAR_3 = (1.0 * ((c / b) - (b / a)));
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.6 |
|---|---|
| Target | 21.1 |
| Herbie | 10.1 |
if b < -1.5993207442876947e-91 or -6.313023766163172e-125 < b < -9.097853122909879e-156Initial program 51.3
Taylor expanded around -inf 11.4
if -1.5993207442876947e-91 < b < -6.313023766163172e-125Initial program 26.5
rmApplied clear-num26.5
rmApplied flip--26.5
Applied associate-/r/26.5
Applied add-cube-cbrt26.5
Applied times-frac26.5
Simplified15.8
Simplified15.8
if -9.097853122909879e-156 < b < 3.9701546350182474e+129Initial program 11.0
rmApplied clear-num11.1
if 3.9701546350182474e+129 < b Initial program 54.3
Taylor expanded around inf 2.0
Simplified2.0
Final simplification10.1
herbie shell --seed 2020106
(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)))