\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 r6990103 = b;
double r6990104 = -r6990103;
double r6990105 = r6990103 * r6990103;
double r6990106 = 4.0;
double r6990107 = a;
double r6990108 = r6990106 * r6990107;
double r6990109 = c;
double r6990110 = r6990108 * r6990109;
double r6990111 = r6990105 - r6990110;
double r6990112 = sqrt(r6990111);
double r6990113 = r6990104 + r6990112;
double r6990114 = 2.0;
double r6990115 = r6990114 * r6990107;
double r6990116 = r6990113 / r6990115;
return r6990116;
}
double f(double a, double b, double c) {
double r6990117 = b;
double r6990118 = -3.7108875578650606e+138;
bool r6990119 = r6990117 <= r6990118;
double r6990120 = 2.0;
double r6990121 = r6990117 / r6990120;
double r6990122 = -2.0;
double r6990123 = r6990121 * r6990122;
double r6990124 = a;
double r6990125 = r6990123 / r6990124;
double r6990126 = 1.627160326743934e-46;
bool r6990127 = r6990117 <= r6990126;
double r6990128 = 1.0;
double r6990129 = sqrt(r6990120);
double r6990130 = sqrt(r6990129);
double r6990131 = r6990128 / r6990130;
double r6990132 = r6990117 * r6990117;
double r6990133 = 4.0;
double r6990134 = r6990133 * r6990124;
double r6990135 = c;
double r6990136 = r6990134 * r6990135;
double r6990137 = r6990132 - r6990136;
double r6990138 = sqrt(r6990137);
double r6990139 = r6990138 - r6990117;
double r6990140 = r6990139 / r6990130;
double r6990141 = r6990140 / r6990129;
double r6990142 = r6990131 * r6990141;
double r6990143 = r6990142 / r6990124;
double r6990144 = -1.0;
double r6990145 = r6990124 * r6990135;
double r6990146 = r6990145 / r6990117;
double r6990147 = r6990144 * r6990146;
double r6990148 = r6990147 / r6990124;
double r6990149 = r6990127 ? r6990143 : r6990148;
double r6990150 = r6990119 ? r6990125 : r6990149;
return r6990150;
}




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)))