\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 -8.1855168042470635 \cdot 10^{-53}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \le 3.634898599408338 \cdot 10^{+146}:\\
\;\;\;\;\frac{\frac{-1}{2} \cdot \left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} + b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2 \cdot \left(\frac{c}{\frac{b}{a}} - b\right)}{2}}{a}\\
\end{array}double f(double a, double b, double c) {
double r2586623 = b;
double r2586624 = -r2586623;
double r2586625 = r2586623 * r2586623;
double r2586626 = 4.0;
double r2586627 = a;
double r2586628 = c;
double r2586629 = r2586627 * r2586628;
double r2586630 = r2586626 * r2586629;
double r2586631 = r2586625 - r2586630;
double r2586632 = sqrt(r2586631);
double r2586633 = r2586624 - r2586632;
double r2586634 = 2.0;
double r2586635 = r2586634 * r2586627;
double r2586636 = r2586633 / r2586635;
return r2586636;
}
double f(double a, double b, double c) {
double r2586637 = b;
double r2586638 = -8.1855168042470635e-53;
bool r2586639 = r2586637 <= r2586638;
double r2586640 = c;
double r2586641 = r2586640 / r2586637;
double r2586642 = -r2586641;
double r2586643 = 3.634898599408338e+146;
bool r2586644 = r2586637 <= r2586643;
double r2586645 = -0.5;
double r2586646 = -4.0;
double r2586647 = r2586646 * r2586640;
double r2586648 = a;
double r2586649 = r2586637 * r2586637;
double r2586650 = fma(r2586647, r2586648, r2586649);
double r2586651 = sqrt(r2586650);
double r2586652 = r2586651 + r2586637;
double r2586653 = r2586645 * r2586652;
double r2586654 = r2586653 / r2586648;
double r2586655 = 2.0;
double r2586656 = r2586637 / r2586648;
double r2586657 = r2586640 / r2586656;
double r2586658 = r2586657 - r2586637;
double r2586659 = r2586655 * r2586658;
double r2586660 = r2586659 / r2586655;
double r2586661 = r2586660 / r2586648;
double r2586662 = r2586644 ? r2586654 : r2586661;
double r2586663 = r2586639 ? r2586642 : r2586662;
return r2586663;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.6 |
|---|---|
| Target | 20.6 |
| Herbie | 9.9 |
if b < -8.1855168042470635e-53Initial program 54.3
Simplified54.3
rmApplied *-un-lft-identity54.3
Applied div-inv54.3
Applied times-frac54.3
Simplified54.3
Simplified54.3
Taylor expanded around -inf 7.5
Simplified7.5
if -8.1855168042470635e-53 < b < 3.634898599408338e+146Initial program 13.3
Simplified13.3
rmApplied *-un-lft-identity13.3
Applied div-inv13.3
Applied times-frac13.4
Simplified13.4
Simplified13.4
rmApplied associate-*r/13.3
Simplified13.3
Taylor expanded around -inf 13.3
Simplified13.3
if 3.634898599408338e+146 < b Initial program 58.5
Simplified58.5
Taylor expanded around inf 10.9
Simplified2.1
Final simplification9.9
herbie shell --seed 2019135 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r2)"
:herbie-target
(if (< b 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)))