\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.710887557865060611891812934492943223731 \cdot 10^{138}:\\
\;\;\;\;\frac{\frac{b}{2} \cdot -2}{a}\\
\mathbf{elif}\;b \le 1.627160326743933989296751920246101845745 \cdot 10^{-46}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\sqrt{2}}} \cdot \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\sqrt{\sqrt{2}}}}{\sqrt{2}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \frac{a \cdot c}{b}}{a}\\
\end{array}double f(double a, double b, double c) {
double r4943995 = b;
double r4943996 = -r4943995;
double r4943997 = r4943995 * r4943995;
double r4943998 = 4.0;
double r4943999 = a;
double r4944000 = r4943998 * r4943999;
double r4944001 = c;
double r4944002 = r4944000 * r4944001;
double r4944003 = r4943997 - r4944002;
double r4944004 = sqrt(r4944003);
double r4944005 = r4943996 + r4944004;
double r4944006 = 2.0;
double r4944007 = r4944006 * r4943999;
double r4944008 = r4944005 / r4944007;
return r4944008;
}
double f(double a, double b, double c) {
double r4944009 = b;
double r4944010 = -3.7108875578650606e+138;
bool r4944011 = r4944009 <= r4944010;
double r4944012 = 2.0;
double r4944013 = r4944009 / r4944012;
double r4944014 = -2.0;
double r4944015 = r4944013 * r4944014;
double r4944016 = a;
double r4944017 = r4944015 / r4944016;
double r4944018 = 1.627160326743934e-46;
bool r4944019 = r4944009 <= r4944018;
double r4944020 = 1.0;
double r4944021 = sqrt(r4944012);
double r4944022 = sqrt(r4944021);
double r4944023 = r4944020 / r4944022;
double r4944024 = r4944009 * r4944009;
double r4944025 = 4.0;
double r4944026 = r4944025 * r4944016;
double r4944027 = c;
double r4944028 = r4944026 * r4944027;
double r4944029 = r4944024 - r4944028;
double r4944030 = sqrt(r4944029);
double r4944031 = r4944030 - r4944009;
double r4944032 = r4944031 / r4944022;
double r4944033 = r4944032 / r4944021;
double r4944034 = r4944023 * r4944033;
double r4944035 = r4944034 / r4944016;
double r4944036 = -1.0;
double r4944037 = r4944016 * r4944027;
double r4944038 = r4944037 / r4944009;
double r4944039 = r4944036 * r4944038;
double r4944040 = r4944039 / r4944016;
double r4944041 = r4944019 ? r4944035 : r4944040;
double r4944042 = r4944011 ? r4944017 : r4944041;
return r4944042;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.2 |
|---|---|
| Target | 21.0 |
| Herbie | 13.8 |
if b < -3.7108875578650606e+138Initial program 58.5
Simplified58.5
rmApplied add-sqr-sqrt58.6
Applied associate-/r*58.6
Taylor expanded around -inf 3.3
Simplified2.1
if -3.7108875578650606e+138 < b < 1.627160326743934e-46Initial program 13.0
Simplified13.0
rmApplied add-sqr-sqrt13.8
Applied associate-/r*13.5
rmApplied *-un-lft-identity13.5
Applied sqrt-prod13.5
Applied add-sqr-sqrt13.5
Applied sqrt-prod13.1
Applied *-un-lft-identity13.1
Applied times-frac13.2
Applied times-frac13.2
Simplified13.2
if 1.627160326743934e-46 < b Initial program 54.2
Simplified54.2
Taylor expanded around inf 18.5
Final simplification13.8
herbie shell --seed 2019174 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r1)"
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))