\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.1214768270116103 \cdot 10^{+154}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \le 1.199441090208904 \cdot 10^{-250}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + \left(-b\right)}\\
\mathbf{elif}\;b \le 3.3389954009657566 \cdot 10^{+124}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}double f(double a, double b, double c) {
double r1499922 = b;
double r1499923 = -r1499922;
double r1499924 = r1499922 * r1499922;
double r1499925 = 4.0;
double r1499926 = a;
double r1499927 = c;
double r1499928 = r1499926 * r1499927;
double r1499929 = r1499925 * r1499928;
double r1499930 = r1499924 - r1499929;
double r1499931 = sqrt(r1499930);
double r1499932 = r1499923 - r1499931;
double r1499933 = 2.0;
double r1499934 = r1499933 * r1499926;
double r1499935 = r1499932 / r1499934;
return r1499935;
}
double f(double a, double b, double c) {
double r1499936 = b;
double r1499937 = -1.1214768270116103e+154;
bool r1499938 = r1499936 <= r1499937;
double r1499939 = c;
double r1499940 = -r1499939;
double r1499941 = r1499940 / r1499936;
double r1499942 = 1.199441090208904e-250;
bool r1499943 = r1499936 <= r1499942;
double r1499944 = 2.0;
double r1499945 = r1499944 * r1499939;
double r1499946 = r1499936 * r1499936;
double r1499947 = 4.0;
double r1499948 = a;
double r1499949 = r1499939 * r1499948;
double r1499950 = r1499947 * r1499949;
double r1499951 = r1499946 - r1499950;
double r1499952 = sqrt(r1499951);
double r1499953 = -r1499936;
double r1499954 = r1499952 + r1499953;
double r1499955 = r1499945 / r1499954;
double r1499956 = 3.3389954009657566e+124;
bool r1499957 = r1499936 <= r1499956;
double r1499958 = r1499953 - r1499952;
double r1499959 = r1499948 * r1499944;
double r1499960 = r1499958 / r1499959;
double r1499961 = r1499953 / r1499948;
double r1499962 = r1499957 ? r1499960 : r1499961;
double r1499963 = r1499943 ? r1499955 : r1499962;
double r1499964 = r1499938 ? r1499941 : r1499963;
return r1499964;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 32.8 |
|---|---|
| Target | 20.1 |
| Herbie | 6.4 |
if b < -1.1214768270116103e+154Initial program 62.9
Taylor expanded around -inf 1.5
Simplified1.5
if -1.1214768270116103e+154 < b < 1.199441090208904e-250Initial program 32.2
rmApplied *-un-lft-identity32.2
Applied *-un-lft-identity32.2
Applied distribute-lft-out--32.2
Applied associate-/l*32.2
rmApplied flip--32.3
Applied associate-/r/32.4
Applied associate-/r*32.4
Simplified32.3
Taylor expanded around -inf 8.4
if 1.199441090208904e-250 < b < 3.3389954009657566e+124Initial program 7.8
if 3.3389954009657566e+124 < b Initial program 50.5
rmApplied *-un-lft-identity50.5
Applied *-un-lft-identity50.5
Applied distribute-lft-out--50.5
Applied associate-/l*50.6
Taylor expanded around 0 3.5
Simplified3.5
Final simplification6.4
herbie shell --seed 2019128
(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)))