\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -1.7431685240570133 \cdot 10^{102}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 1.0417939395900796 \cdot 10^{-259}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{elif}\;b \le 9.37351117144741807 \cdot 10^{103}:\\
\;\;\;\;\frac{1}{2 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)} \cdot \left(\frac{4}{1} \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r118066 = b;
double r118067 = -r118066;
double r118068 = r118066 * r118066;
double r118069 = 4.0;
double r118070 = a;
double r118071 = r118069 * r118070;
double r118072 = c;
double r118073 = r118071 * r118072;
double r118074 = r118068 - r118073;
double r118075 = sqrt(r118074);
double r118076 = r118067 + r118075;
double r118077 = 2.0;
double r118078 = r118077 * r118070;
double r118079 = r118076 / r118078;
return r118079;
}
double f(double a, double b, double c) {
double r118080 = b;
double r118081 = -1.7431685240570133e+102;
bool r118082 = r118080 <= r118081;
double r118083 = 1.0;
double r118084 = c;
double r118085 = r118084 / r118080;
double r118086 = a;
double r118087 = r118080 / r118086;
double r118088 = r118085 - r118087;
double r118089 = r118083 * r118088;
double r118090 = 1.0417939395900796e-259;
bool r118091 = r118080 <= r118090;
double r118092 = -r118080;
double r118093 = r118080 * r118080;
double r118094 = 4.0;
double r118095 = r118094 * r118086;
double r118096 = r118095 * r118084;
double r118097 = r118093 - r118096;
double r118098 = sqrt(r118097);
double r118099 = r118092 + r118098;
double r118100 = 2.0;
double r118101 = r118100 * r118086;
double r118102 = r118099 / r118101;
double r118103 = 9.373511171447418e+103;
bool r118104 = r118080 <= r118103;
double r118105 = 1.0;
double r118106 = r118092 - r118098;
double r118107 = r118100 * r118106;
double r118108 = r118105 / r118107;
double r118109 = r118094 / r118105;
double r118110 = r118109 * r118084;
double r118111 = r118108 * r118110;
double r118112 = -1.0;
double r118113 = r118112 * r118085;
double r118114 = r118104 ? r118111 : r118113;
double r118115 = r118091 ? r118102 : r118114;
double r118116 = r118082 ? r118089 : r118115;
return r118116;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.1 |
|---|---|
| Target | 20.5 |
| Herbie | 6.5 |
if b < -1.7431685240570133e+102Initial program 47.5
Taylor expanded around -inf 3.1
Simplified3.1
if -1.7431685240570133e+102 < b < 1.0417939395900796e-259Initial program 9.7
if 1.0417939395900796e-259 < b < 9.373511171447418e+103Initial program 34.9
rmApplied flip-+35.0
Simplified17.0
rmApplied *-un-lft-identity17.0
Applied *-un-lft-identity17.0
Applied times-frac17.0
Applied associate-/l*17.3
Simplified16.1
rmApplied associate-/l*16.1
Simplified8.3
rmApplied associate-*l/8.2
Applied associate-/r/7.8
Simplified7.8
if 9.373511171447418e+103 < b Initial program 59.9
Taylor expanded around inf 2.3
Final simplification6.5
herbie shell --seed 2020024
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.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)))