\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 -0.04248736169027556:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le -7.2720221422685763 \cdot 10^{-101}:\\
\;\;\;\;\frac{\sqrt[3]{\frac{1}{2 \cdot a}} \cdot \sqrt[3]{\frac{1}{2 \cdot a}}}{\frac{\frac{1}{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}}}{\sqrt[3]{\frac{1}{2 \cdot a}}}}\\
\mathbf{elif}\;b \le 5.3362850167303113 \cdot 10^{150}:\\
\;\;\;\;\frac{\frac{1}{2 \cdot a}}{\frac{1}{\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 <= -0.04248736169027556)) {
VAR = (-1.0 * (c / b));
} else {
double VAR_1;
if ((b <= -7.272022142268576e-101)) {
VAR_1 = ((cbrt((1.0 / (2.0 * a))) * cbrt((1.0 / (2.0 * a)))) / ((1.0 / ((0.0 + (4.0 * (a * c))) / (sqrt(((b * b) - (4.0 * (a * c)))) - b))) / cbrt((1.0 / (2.0 * a)))));
} else {
double VAR_2;
if ((b <= 5.336285016730311e+150)) {
VAR_2 = ((1.0 / (2.0 * a)) / (1.0 / (-b - sqrt(((b * b) - (4.0 * (a * c)))))));
} 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.1 |
|---|---|
| Target | 20.9 |
| Herbie | 9.3 |
if b < -0.04248736169027556Initial program 56.1
Taylor expanded around -inf 5.6
if -0.04248736169027556 < b < -7.272022142268576e-101Initial program 37.3
rmApplied clear-num37.3
rmApplied div-inv37.3
Applied associate-/r*37.3
rmApplied add-cube-cbrt37.7
Applied associate-/l*37.7
rmApplied flip--37.7
Simplified17.4
Simplified17.4
if -7.272022142268576e-101 < b < 5.336285016730311e+150Initial program 11.9
rmApplied clear-num12.0
rmApplied div-inv12.0
Applied associate-/r*12.0
if 5.336285016730311e+150 < b Initial program 62.8
Taylor expanded around inf 2.2
Simplified2.2
Final simplification9.3
herbie shell --seed 2020105 +o rules:numerics
(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)))