\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.515406138267436 \cdot 10^{+130}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \le -4.320492610336173 \cdot 10^{-222}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} + \left(-b\right)}\\
\mathbf{elif}\;b \le 5.000815192005961 \cdot 10^{+134}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}double f(double a, double b, double c) {
double r6982486 = b;
double r6982487 = -r6982486;
double r6982488 = r6982486 * r6982486;
double r6982489 = 4.0;
double r6982490 = a;
double r6982491 = c;
double r6982492 = r6982490 * r6982491;
double r6982493 = r6982489 * r6982492;
double r6982494 = r6982488 - r6982493;
double r6982495 = sqrt(r6982494);
double r6982496 = r6982487 - r6982495;
double r6982497 = 2.0;
double r6982498 = r6982497 * r6982490;
double r6982499 = r6982496 / r6982498;
return r6982499;
}
double f(double a, double b, double c) {
double r6982500 = b;
double r6982501 = -1.515406138267436e+130;
bool r6982502 = r6982500 <= r6982501;
double r6982503 = c;
double r6982504 = r6982503 / r6982500;
double r6982505 = -r6982504;
double r6982506 = -4.320492610336173e-222;
bool r6982507 = r6982500 <= r6982506;
double r6982508 = 2.0;
double r6982509 = r6982508 * r6982503;
double r6982510 = r6982500 * r6982500;
double r6982511 = a;
double r6982512 = -4.0;
double r6982513 = r6982512 * r6982503;
double r6982514 = r6982511 * r6982513;
double r6982515 = r6982510 + r6982514;
double r6982516 = sqrt(r6982515);
double r6982517 = -r6982500;
double r6982518 = r6982516 + r6982517;
double r6982519 = r6982509 / r6982518;
double r6982520 = 5.000815192005961e+134;
bool r6982521 = r6982500 <= r6982520;
double r6982522 = r6982517 - r6982516;
double r6982523 = r6982511 * r6982508;
double r6982524 = r6982522 / r6982523;
double r6982525 = r6982500 / r6982511;
double r6982526 = r6982504 - r6982525;
double r6982527 = r6982521 ? r6982524 : r6982526;
double r6982528 = r6982507 ? r6982519 : r6982527;
double r6982529 = r6982502 ? r6982505 : r6982528;
return r6982529;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 32.9 |
|---|---|
| Target | 20.6 |
| Herbie | 6.8 |
if b < -1.515406138267436e+130Initial program 60.2
Taylor expanded around -inf 60.2
Simplified60.2
Taylor expanded around -inf 2.3
Simplified2.3
if -1.515406138267436e+130 < b < -4.320492610336173e-222Initial program 36.2
Taylor expanded around -inf 36.2
Simplified36.2
rmApplied div-inv36.2
rmApplied flip--36.3
Applied associate-*l/36.3
Simplified14.6
Taylor expanded around 0 7.2
if -4.320492610336173e-222 < b < 5.000815192005961e+134Initial program 9.7
Taylor expanded around -inf 9.7
Simplified9.8
if 5.000815192005961e+134 < b Initial program 53.5
Taylor expanded around -inf 53.5
Simplified53.5
Taylor expanded around inf 3.5
Final simplification6.8
herbie shell --seed 2019121
(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)))