\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 -3.450829996567047685966692456342790556879 \cdot 10^{138}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\
\mathbf{elif}\;b \le 4.626043257219637986942022736183111936335 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{1}{2}}{a} \cdot \left(\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -1\\
\end{array}double f(double a, double b, double c) {
double r3530991 = b;
double r3530992 = -r3530991;
double r3530993 = r3530991 * r3530991;
double r3530994 = 4.0;
double r3530995 = a;
double r3530996 = c;
double r3530997 = r3530995 * r3530996;
double r3530998 = r3530994 * r3530997;
double r3530999 = r3530993 - r3530998;
double r3531000 = sqrt(r3530999);
double r3531001 = r3530992 + r3531000;
double r3531002 = 2.0;
double r3531003 = r3531002 * r3530995;
double r3531004 = r3531001 / r3531003;
return r3531004;
}
double f(double a, double b, double c) {
double r3531005 = b;
double r3531006 = -3.450829996567048e+138;
bool r3531007 = r3531005 <= r3531006;
double r3531008 = c;
double r3531009 = r3531008 / r3531005;
double r3531010 = a;
double r3531011 = r3531005 / r3531010;
double r3531012 = r3531009 - r3531011;
double r3531013 = 1.0;
double r3531014 = r3531012 * r3531013;
double r3531015 = 4.626043257219638e-62;
bool r3531016 = r3531005 <= r3531015;
double r3531017 = 1.0;
double r3531018 = 2.0;
double r3531019 = r3531017 / r3531018;
double r3531020 = r3531019 / r3531010;
double r3531021 = r3531005 * r3531005;
double r3531022 = 4.0;
double r3531023 = r3531008 * r3531022;
double r3531024 = r3531023 * r3531010;
double r3531025 = r3531021 - r3531024;
double r3531026 = sqrt(r3531025);
double r3531027 = r3531026 - r3531005;
double r3531028 = r3531020 * r3531027;
double r3531029 = -1.0;
double r3531030 = r3531009 * r3531029;
double r3531031 = r3531016 ? r3531028 : r3531030;
double r3531032 = r3531007 ? r3531014 : r3531031;
return r3531032;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.2 |
|---|---|
| Target | 21.0 |
| Herbie | 9.6 |
if b < -3.450829996567048e+138Initial program 58.5
Simplified58.5
rmApplied add-cube-cbrt58.5
Applied associate-*r*58.5
rmApplied *-un-lft-identity58.5
Applied *-un-lft-identity58.5
Applied distribute-lft-out--58.5
Simplified58.5
Taylor expanded around -inf 2.0
Simplified2.0
if -3.450829996567048e+138 < b < 4.626043257219638e-62Initial program 12.3
Simplified12.3
rmApplied add-cube-cbrt12.6
Applied associate-*r*12.6
rmApplied *-un-lft-identity12.6
Applied *-un-lft-identity12.6
Applied distribute-lft-out--12.6
Simplified12.3
rmApplied *-un-lft-identity12.3
Applied div-inv12.3
Applied times-frac12.4
Simplified12.4
if 4.626043257219638e-62 < b Initial program 53.7
Simplified53.7
rmApplied add-cube-cbrt53.8
Applied associate-*r*53.8
rmApplied *-un-lft-identity53.8
Applied *-un-lft-identity53.8
Applied distribute-lft-out--53.8
Simplified53.7
Taylor expanded around inf 8.5
Final simplification9.6
herbie shell --seed 2019174
(FPCore (a b c)
:name "quadp (p42, positive)"
: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)))