\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 -3.27328871966128296 \cdot 10^{120}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -1.7838017938976764 \cdot 10^{-303}:\\
\;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\
\mathbf{elif}\;b \le 7.2373138236866389 \cdot 10^{64}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{4}{\frac{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{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 temp;
if ((b <= -3.273288719661283e+120)) {
temp = (1.0 * ((c / b) - (b / a)));
} else {
double temp_1;
if ((b <= -1.7838017938976764e-303)) {
temp_1 = ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) * (1.0 / (2.0 * a)));
} else {
double temp_2;
if ((b <= 7.237313823686639e+64)) {
temp_2 = ((1.0 / 2.0) * (4.0 / ((1.0 * (-b - sqrt(((b * b) - ((4.0 * a) * c))))) / c)));
} else {
temp_2 = (-1.0 * (c / b));
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.0 |
|---|---|
| Target | 20.7 |
| Herbie | 6.6 |
if b < -3.273288719661283e+120Initial program 52.6
Taylor expanded around -inf 2.9
Simplified2.9
if -3.273288719661283e+120 < b < -1.7838017938976764e-303Initial program 8.8
rmApplied div-inv8.9
if -1.7838017938976764e-303 < b < 7.237313823686639e+64Initial program 29.4
rmApplied flip-+29.4
Simplified15.7
rmApplied *-un-lft-identity15.7
Applied *-un-lft-identity15.7
Applied times-frac15.7
Applied times-frac15.8
Simplified15.8
Simplified21.3
rmApplied associate-/l*21.5
Simplified9.0
if 7.237313823686639e+64 < b Initial program 57.3
Taylor expanded around inf 3.5
Final simplification6.6
herbie shell --seed 2020057
(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)))