\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.8774910265390396 \cdot 10^{-73}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \le 2.5703497435733685 \cdot 10^{+102}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} + b}{a} \cdot \frac{-1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}double f(double a, double b, double c) {
double r1570301 = b;
double r1570302 = -r1570301;
double r1570303 = r1570301 * r1570301;
double r1570304 = 4.0;
double r1570305 = a;
double r1570306 = c;
double r1570307 = r1570305 * r1570306;
double r1570308 = r1570304 * r1570307;
double r1570309 = r1570303 - r1570308;
double r1570310 = sqrt(r1570309);
double r1570311 = r1570302 - r1570310;
double r1570312 = 2.0;
double r1570313 = r1570312 * r1570305;
double r1570314 = r1570311 / r1570313;
return r1570314;
}
double f(double a, double b, double c) {
double r1570315 = b;
double r1570316 = -1.8774910265390396e-73;
bool r1570317 = r1570315 <= r1570316;
double r1570318 = c;
double r1570319 = r1570318 / r1570315;
double r1570320 = -r1570319;
double r1570321 = 2.5703497435733685e+102;
bool r1570322 = r1570315 <= r1570321;
double r1570323 = r1570315 * r1570315;
double r1570324 = 4.0;
double r1570325 = r1570318 * r1570324;
double r1570326 = a;
double r1570327 = r1570325 * r1570326;
double r1570328 = r1570323 - r1570327;
double r1570329 = sqrt(r1570328);
double r1570330 = r1570329 + r1570315;
double r1570331 = r1570330 / r1570326;
double r1570332 = -0.5;
double r1570333 = r1570331 * r1570332;
double r1570334 = r1570315 / r1570326;
double r1570335 = r1570319 - r1570334;
double r1570336 = r1570322 ? r1570333 : r1570335;
double r1570337 = r1570317 ? r1570320 : r1570336;
return r1570337;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.2 |
|---|---|
| Target | 20.4 |
| Herbie | 9.8 |
if b < -1.8774910265390396e-73Initial program 52.5
Taylor expanded around -inf 52.5
Simplified52.5
Taylor expanded around -inf 8.6
Simplified8.6
if -1.8774910265390396e-73 < b < 2.5703497435733685e+102Initial program 13.1
Taylor expanded around -inf 13.1
Simplified13.1
rmApplied *-un-lft-identity13.1
Applied *-un-lft-identity13.1
Applied distribute-rgt-neg-in13.1
Applied distribute-lft-out--13.1
Applied associate-/l*13.2
rmApplied *-un-lft-identity13.2
Applied times-frac13.2
Applied add-sqr-sqrt13.2
Applied times-frac13.2
Simplified13.2
Simplified13.1
if 2.5703497435733685e+102 < b Initial program 43.9
Taylor expanded around inf 2.9
Final simplification9.8
herbie shell --seed 2019153
(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)))