\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 -1.11981154530853106611761327467786604265 \cdot 10^{143}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 4.718890261991468628346768591871377778707 \cdot 10^{-106}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r168256 = b;
double r168257 = -r168256;
double r168258 = r168256 * r168256;
double r168259 = 4.0;
double r168260 = a;
double r168261 = r168259 * r168260;
double r168262 = c;
double r168263 = r168261 * r168262;
double r168264 = r168258 - r168263;
double r168265 = sqrt(r168264);
double r168266 = r168257 + r168265;
double r168267 = 2.0;
double r168268 = r168267 * r168260;
double r168269 = r168266 / r168268;
return r168269;
}
double f(double a, double b, double c) {
double r168270 = b;
double r168271 = -1.119811545308531e+143;
bool r168272 = r168270 <= r168271;
double r168273 = 1.0;
double r168274 = c;
double r168275 = r168274 / r168270;
double r168276 = a;
double r168277 = r168270 / r168276;
double r168278 = r168275 - r168277;
double r168279 = r168273 * r168278;
double r168280 = 4.718890261991469e-106;
bool r168281 = r168270 <= r168280;
double r168282 = r168270 * r168270;
double r168283 = 4.0;
double r168284 = r168283 * r168276;
double r168285 = r168284 * r168274;
double r168286 = r168282 - r168285;
double r168287 = sqrt(r168286);
double r168288 = r168287 - r168270;
double r168289 = 2.0;
double r168290 = r168289 * r168276;
double r168291 = r168288 / r168290;
double r168292 = -1.0;
double r168293 = r168292 * r168275;
double r168294 = r168281 ? r168291 : r168293;
double r168295 = r168272 ? r168279 : r168294;
return r168295;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.1 |
|---|---|
| Target | 21.0 |
| Herbie | 10.0 |
if b < -1.119811545308531e+143Initial program 59.0
Simplified59.0
rmApplied div-inv59.0
rmApplied *-un-lft-identity59.0
Applied associate-*l*59.0
Simplified59.0
Taylor expanded around -inf 2.4
Simplified2.4
if -1.119811545308531e+143 < b < 4.718890261991469e-106Initial program 11.1
Simplified11.1
rmApplied div-inv11.2
rmApplied *-un-lft-identity11.2
Applied associate-*l*11.2
Simplified11.1
if 4.718890261991469e-106 < b Initial program 52.4
Simplified52.4
Taylor expanded around inf 10.9
Final simplification10.0
herbie shell --seed 2019326
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))