\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 5.719882815963251 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{1}{2}}{a} \cdot \left(\sqrt{\mathsf{fma}\left(a, \left(-4 \cdot c\right), \left(b \cdot b\right)\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}double f(double a, double b, double c) {
double r2468495 = b;
double r2468496 = -r2468495;
double r2468497 = r2468495 * r2468495;
double r2468498 = 4.0;
double r2468499 = a;
double r2468500 = c;
double r2468501 = r2468499 * r2468500;
double r2468502 = r2468498 * r2468501;
double r2468503 = r2468497 - r2468502;
double r2468504 = sqrt(r2468503);
double r2468505 = r2468496 + r2468504;
double r2468506 = 2.0;
double r2468507 = r2468506 * r2468499;
double r2468508 = r2468505 / r2468507;
return r2468508;
}
double f(double a, double b, double c) {
double r2468509 = b;
double r2468510 = 5.719882815963251e+100;
bool r2468511 = r2468509 <= r2468510;
double r2468512 = 0.5;
double r2468513 = a;
double r2468514 = r2468512 / r2468513;
double r2468515 = -4.0;
double r2468516 = c;
double r2468517 = r2468515 * r2468516;
double r2468518 = r2468509 * r2468509;
double r2468519 = fma(r2468513, r2468517, r2468518);
double r2468520 = sqrt(r2468519);
double r2468521 = r2468520 - r2468509;
double r2468522 = r2468514 * r2468521;
double r2468523 = 0.0;
double r2468524 = r2468511 ? r2468522 : r2468523;
return r2468524;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.6 |
|---|---|
| Target | 20.8 |
| Herbie | 29.4 |
if b < 5.719882815963251e+100Initial program 25.8
Simplified25.8
rmApplied *-un-lft-identity25.8
Applied div-inv25.8
Applied times-frac25.9
Simplified25.9
Simplified25.9
if 5.719882815963251e+100 < b Initial program 58.7
Simplified58.7
rmApplied clear-num58.7
rmApplied div-inv58.7
Applied *-un-lft-identity58.7
Applied times-frac58.7
Applied associate-/r*58.7
Simplified58.7
Taylor expanded around 0 40.5
Final simplification29.4
herbie shell --seed 2019130 +o rules:numerics
(FPCore (a b c)
:name "quadp (p42, positive)"
:herbie-target
(if (< b 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)))