\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.5961406266953245 \cdot 10^{-58}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \le 3.1115579814291686 \cdot 10^{+29}:\\
\;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}double f(double a, double b, double c) {
double r3200023 = b;
double r3200024 = -r3200023;
double r3200025 = r3200023 * r3200023;
double r3200026 = 4.0;
double r3200027 = a;
double r3200028 = c;
double r3200029 = r3200027 * r3200028;
double r3200030 = r3200026 * r3200029;
double r3200031 = r3200025 - r3200030;
double r3200032 = sqrt(r3200031);
double r3200033 = r3200024 - r3200032;
double r3200034 = 2.0;
double r3200035 = r3200034 * r3200027;
double r3200036 = r3200033 / r3200035;
return r3200036;
}
double f(double a, double b, double c) {
double r3200037 = b;
double r3200038 = -1.5961406266953245e-58;
bool r3200039 = r3200037 <= r3200038;
double r3200040 = c;
double r3200041 = r3200040 / r3200037;
double r3200042 = -r3200041;
double r3200043 = 3.1115579814291686e+29;
bool r3200044 = r3200037 <= r3200043;
double r3200045 = 1.0;
double r3200046 = 2.0;
double r3200047 = a;
double r3200048 = r3200046 * r3200047;
double r3200049 = -r3200037;
double r3200050 = r3200037 * r3200037;
double r3200051 = r3200047 * r3200040;
double r3200052 = 4.0;
double r3200053 = r3200051 * r3200052;
double r3200054 = r3200050 - r3200053;
double r3200055 = sqrt(r3200054);
double r3200056 = r3200049 - r3200055;
double r3200057 = r3200048 / r3200056;
double r3200058 = r3200045 / r3200057;
double r3200059 = r3200049 / r3200047;
double r3200060 = r3200044 ? r3200058 : r3200059;
double r3200061 = r3200039 ? r3200042 : r3200060;
return r3200061;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.9 |
|---|---|
| Target | 20.6 |
| Herbie | 10.5 |
if b < -1.5961406266953245e-58Initial program 53.4
Taylor expanded around -inf 53.4
Simplified53.4
Taylor expanded around -inf 8.1
Simplified8.1
if -1.5961406266953245e-58 < b < 3.1115579814291686e+29Initial program 14.7
Taylor expanded around -inf 14.7
Simplified14.7
rmApplied *-un-lft-identity14.7
Applied associate-/l*14.9
if 3.1115579814291686e+29 < b Initial program 34.4
Taylor expanded around -inf 34.4
Simplified34.4
rmApplied *-un-lft-identity34.4
Applied associate-/l*34.5
rmApplied associate-/r/34.5
Taylor expanded around 0 6.5
Simplified6.5
Final simplification10.5
herbie shell --seed 2019134 +o rules:numerics
(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)))