\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 -1.264659490877097952776006549579654784856 \cdot 10^{-67}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 0.173897874048477174557802982235443778336:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\
\end{array}double f(double a, double b, double c) {
double r4467155 = b;
double r4467156 = -r4467155;
double r4467157 = r4467155 * r4467155;
double r4467158 = 4.0;
double r4467159 = a;
double r4467160 = c;
double r4467161 = r4467159 * r4467160;
double r4467162 = r4467158 * r4467161;
double r4467163 = r4467157 - r4467162;
double r4467164 = sqrt(r4467163);
double r4467165 = r4467156 - r4467164;
double r4467166 = 2.0;
double r4467167 = r4467166 * r4467159;
double r4467168 = r4467165 / r4467167;
return r4467168;
}
double f(double a, double b, double c) {
double r4467169 = b;
double r4467170 = -1.264659490877098e-67;
bool r4467171 = r4467169 <= r4467170;
double r4467172 = -1.0;
double r4467173 = c;
double r4467174 = r4467173 / r4467169;
double r4467175 = r4467172 * r4467174;
double r4467176 = 0.17389787404847717;
bool r4467177 = r4467169 <= r4467176;
double r4467178 = -r4467169;
double r4467179 = r4467169 * r4467169;
double r4467180 = a;
double r4467181 = 4.0;
double r4467182 = r4467181 * r4467173;
double r4467183 = r4467180 * r4467182;
double r4467184 = r4467179 - r4467183;
double r4467185 = sqrt(r4467184);
double r4467186 = r4467178 - r4467185;
double r4467187 = 2.0;
double r4467188 = r4467187 * r4467180;
double r4467189 = r4467186 / r4467188;
double r4467190 = r4467169 / r4467180;
double r4467191 = r4467174 - r4467190;
double r4467192 = 1.0;
double r4467193 = r4467191 * r4467192;
double r4467194 = r4467177 ? r4467189 : r4467193;
double r4467195 = r4467171 ? r4467175 : r4467194;
return r4467195;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 21.3 |
| Herbie | 10.5 |
if b < -1.264659490877098e-67Initial program 53.5
Taylor expanded around -inf 8.1
if -1.264659490877098e-67 < b < 0.17389787404847717Initial program 15.3
rmApplied div-inv15.4
rmApplied *-un-lft-identity15.4
Applied times-frac15.4
Applied associate-*r*15.4
Simplified15.4
rmApplied frac-times15.3
Simplified15.3
if 0.17389787404847717 < b Initial program 31.2
rmApplied div-inv31.3
rmApplied *-un-lft-identity31.3
Applied times-frac31.3
Applied associate-*r*31.3
Simplified31.3
Taylor expanded around inf 7.3
Simplified7.3
Final simplification10.5
herbie shell --seed 2019168
(FPCore (a b c)
:name "The quadratic formula (r2)"
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))