\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 -4.8085485579241775 \cdot 10^{39}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 2.7444235711350233 \cdot 10^{-95}:\\
\;\;\;\;\frac{\frac{\frac{1}{2} \cdot \left(\left({b}^{2} - {b}^{2}\right) + 4 \cdot \left(a \cdot c\right)\right)}{a}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\mathbf{elif}\;b \le 7.3698697747524969 \cdot 10^{119}:\\
\;\;\;\;\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 <= -4.8085485579241775e+39)) {
temp = (-1.0 * (c / b));
} else {
double temp_1;
if ((b <= 2.7444235711350233e-95)) {
temp_1 = ((((1.0 / 2.0) * ((pow(b, 2.0) - pow(b, 2.0)) + (4.0 * (a * c)))) / a) / (-b + sqrt(((b * b) - (4.0 * (a * c))))));
} else {
double temp_2;
if ((b <= 7.369869774752497e+119)) {
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 | 9.3 |
if b < -4.8085485579241775e+39Initial program 57.2
Taylor expanded around -inf 3.8
if -4.8085485579241775e+39 < b < 2.7444235711350233e-95Initial program 23.1
rmApplied clear-num23.2
rmApplied flip--25.5
Applied associate-/r/25.5
Applied associate-/r*25.5
Simplified17.6
if 2.7444235711350233e-95 < b < 7.369869774752497e+119Initial program 5.3
rmApplied div-inv5.5
if 7.369869774752497e+119 < b Initial program 52.0
rmApplied clear-num52.0
Taylor expanded around 0 2.4
Final simplification9.3
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)))