\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 -2.0697892322852844 \cdot 10^{57}:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\
\mathbf{elif}\;b \le 5.08229739317807349 \cdot 10^{-29}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{b} \cdot \sqrt[3]{b}, -\sqrt[3]{b}, \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{2 \cdot a}\\
\end{array}double f(double a, double b, double c) {
double r101309 = b;
double r101310 = -r101309;
double r101311 = r101309 * r101309;
double r101312 = 4.0;
double r101313 = a;
double r101314 = r101312 * r101313;
double r101315 = c;
double r101316 = r101314 * r101315;
double r101317 = r101311 - r101316;
double r101318 = sqrt(r101317);
double r101319 = r101310 + r101318;
double r101320 = 2.0;
double r101321 = r101320 * r101313;
double r101322 = r101319 / r101321;
return r101322;
}
double f(double a, double b, double c) {
double r101323 = b;
double r101324 = -2.0697892322852844e+57;
bool r101325 = r101323 <= r101324;
double r101326 = 2.0;
double r101327 = a;
double r101328 = c;
double r101329 = r101327 * r101328;
double r101330 = r101329 / r101323;
double r101331 = r101326 * r101330;
double r101332 = 2.0;
double r101333 = r101332 * r101323;
double r101334 = r101331 - r101333;
double r101335 = r101326 * r101327;
double r101336 = r101334 / r101335;
double r101337 = 5.082297393178073e-29;
bool r101338 = r101323 <= r101337;
double r101339 = cbrt(r101323);
double r101340 = r101339 * r101339;
double r101341 = -r101339;
double r101342 = r101323 * r101323;
double r101343 = 4.0;
double r101344 = r101343 * r101327;
double r101345 = r101344 * r101328;
double r101346 = r101342 - r101345;
double r101347 = sqrt(r101346);
double r101348 = fma(r101340, r101341, r101347);
double r101349 = r101348 / r101335;
double r101350 = -2.0;
double r101351 = r101350 * r101330;
double r101352 = r101351 / r101335;
double r101353 = r101338 ? r101349 : r101352;
double r101354 = r101325 ? r101336 : r101353;
return r101354;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 34.2 |
|---|---|
| Target | 21.1 |
| Herbie | 15.4 |
if b < -2.0697892322852844e+57Initial program 39.1
rmApplied add-cube-cbrt39.2
Applied associate-*r*39.2
rmApplied add-cube-cbrt39.2
Taylor expanded around -inf 10.0
if -2.0697892322852844e+57 < b < 5.082297393178073e-29Initial program 16.0
rmApplied add-cube-cbrt16.2
Applied distribute-rgt-neg-in16.2
Applied fma-def16.2
if 5.082297393178073e-29 < b Initial program 54.3
Taylor expanded around inf 17.5
Final simplification15.4
herbie shell --seed 2020033 +o rules:numerics
(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)))