\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -3.0775171197265305 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{2.0}}{a}\\
\mathbf{elif}\;b \le -6.459611810046018 \cdot 10^{-256}:\\
\;\;\;\;\left(\sqrt{b \cdot b - 4.0 \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{\frac{1}{2.0}}{a}\\
\mathbf{elif}\;b \le 5.413497103300552 \cdot 10^{+144}:\\
\;\;\;\;\frac{c \cdot -2.0}{\sqrt{b \cdot b - 4.0 \cdot \left(a \cdot c\right)} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -1.0\\
\end{array}double f(double a, double b, double c) {
double r4103336 = b;
double r4103337 = -r4103336;
double r4103338 = r4103336 * r4103336;
double r4103339 = 4.0;
double r4103340 = a;
double r4103341 = r4103339 * r4103340;
double r4103342 = c;
double r4103343 = r4103341 * r4103342;
double r4103344 = r4103338 - r4103343;
double r4103345 = sqrt(r4103344);
double r4103346 = r4103337 + r4103345;
double r4103347 = 2.0;
double r4103348 = r4103347 * r4103340;
double r4103349 = r4103346 / r4103348;
return r4103349;
}
double f(double a, double b, double c) {
double r4103350 = b;
double r4103351 = -3.0775171197265305e+143;
bool r4103352 = r4103350 <= r4103351;
double r4103353 = -2.0;
double r4103354 = r4103353 * r4103350;
double r4103355 = 2.0;
double r4103356 = r4103354 / r4103355;
double r4103357 = a;
double r4103358 = r4103356 / r4103357;
double r4103359 = -6.459611810046018e-256;
bool r4103360 = r4103350 <= r4103359;
double r4103361 = r4103350 * r4103350;
double r4103362 = 4.0;
double r4103363 = c;
double r4103364 = r4103357 * r4103363;
double r4103365 = r4103362 * r4103364;
double r4103366 = r4103361 - r4103365;
double r4103367 = sqrt(r4103366);
double r4103368 = r4103367 - r4103350;
double r4103369 = 1.0;
double r4103370 = r4103369 / r4103355;
double r4103371 = r4103370 / r4103357;
double r4103372 = r4103368 * r4103371;
double r4103373 = 5.413497103300552e+144;
bool r4103374 = r4103350 <= r4103373;
double r4103375 = -2.0;
double r4103376 = r4103363 * r4103375;
double r4103377 = r4103367 + r4103350;
double r4103378 = r4103376 / r4103377;
double r4103379 = r4103363 / r4103350;
double r4103380 = -1.0;
double r4103381 = r4103379 * r4103380;
double r4103382 = r4103374 ? r4103378 : r4103381;
double r4103383 = r4103360 ? r4103372 : r4103382;
double r4103384 = r4103352 ? r4103358 : r4103383;
return r4103384;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.5 |
|---|---|
| Target | 20.9 |
| Herbie | 6.3 |
if b < -3.0775171197265305e+143Initial program 59.8
Simplified59.8
rmApplied add-sqr-sqrt59.8
Applied sqrt-prod59.8
Applied fma-neg59.8
Taylor expanded around -inf 3.0
Simplified3.0
if -3.0775171197265305e+143 < b < -6.459611810046018e-256Initial program 8.0
Simplified7.9
rmApplied *-un-lft-identity7.9
Applied div-inv7.9
Applied times-frac8.1
Simplified8.1
if -6.459611810046018e-256 < b < 5.413497103300552e+144Initial program 33.1
Simplified33.1
rmApplied *-un-lft-identity33.1
Applied div-inv33.1
Applied times-frac33.1
Simplified33.1
rmApplied flip--33.2
Applied associate-*l/33.2
Simplified13.6
Taylor expanded around 0 8.3
if 5.413497103300552e+144 < b Initial program 62.8
Simplified62.8
Taylor expanded around inf 1.4
Final simplification6.3
herbie shell --seed 2019165 +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)))