\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.532647813487865 \cdot 10^{52}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le -1.571246895950166 \cdot 10^{-147}:\\
\;\;\;\;\frac{\frac{\left(4 \cdot c\right) \cdot a}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}}{2 \cdot a}\\
\mathbf{elif}\;b \le 6.63703793523525319 \cdot 10^{98}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\end{array}double f(double a, double b, double c) {
double r56144 = b;
double r56145 = -r56144;
double r56146 = r56144 * r56144;
double r56147 = 4.0;
double r56148 = a;
double r56149 = c;
double r56150 = r56148 * r56149;
double r56151 = r56147 * r56150;
double r56152 = r56146 - r56151;
double r56153 = sqrt(r56152);
double r56154 = r56145 - r56153;
double r56155 = 2.0;
double r56156 = r56155 * r56148;
double r56157 = r56154 / r56156;
return r56157;
}
double f(double a, double b, double c) {
double r56158 = b;
double r56159 = -1.532647813487865e+52;
bool r56160 = r56158 <= r56159;
double r56161 = -1.0;
double r56162 = c;
double r56163 = r56162 / r56158;
double r56164 = r56161 * r56163;
double r56165 = -1.571246895950166e-147;
bool r56166 = r56158 <= r56165;
double r56167 = 4.0;
double r56168 = r56167 * r56162;
double r56169 = a;
double r56170 = r56168 * r56169;
double r56171 = r56158 * r56158;
double r56172 = r56169 * r56162;
double r56173 = r56167 * r56172;
double r56174 = r56171 - r56173;
double r56175 = sqrt(r56174);
double r56176 = r56175 - r56158;
double r56177 = r56170 / r56176;
double r56178 = 2.0;
double r56179 = r56178 * r56169;
double r56180 = r56177 / r56179;
double r56181 = 6.637037935235253e+98;
bool r56182 = r56158 <= r56181;
double r56183 = -r56158;
double r56184 = r56183 - r56175;
double r56185 = r56184 / r56179;
double r56186 = 1.0;
double r56187 = r56158 / r56169;
double r56188 = r56163 - r56187;
double r56189 = r56186 * r56188;
double r56190 = r56182 ? r56185 : r56189;
double r56191 = r56166 ? r56180 : r56190;
double r56192 = r56160 ? r56164 : r56191;
return r56192;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.4 |
|---|---|
| Target | 21.0 |
| Herbie | 9.0 |
if b < -1.532647813487865e+52Initial program 57.3
rmApplied clear-num57.3
rmApplied div-inv57.3
Applied add-cube-cbrt57.3
Applied times-frac57.3
Simplified57.3
Simplified57.3
rmApplied *-un-lft-identity57.3
Applied associate-*l*57.3
Simplified57.3
Taylor expanded around -inf 3.6
if -1.532647813487865e+52 < b < -1.571246895950166e-147Initial program 37.2
rmApplied flip--37.2
Simplified16.9
Simplified16.9
if -1.571246895950166e-147 < b < 6.637037935235253e+98Initial program 11.7
rmApplied clear-num11.8
rmApplied div-inv11.9
Applied add-cube-cbrt11.9
Applied times-frac11.9
Simplified11.9
Simplified11.8
rmApplied *-un-lft-identity11.8
Applied associate-*l*11.8
Simplified11.7
if 6.637037935235253e+98 < b Initial program 47.9
Taylor expanded around inf 3.7
Simplified3.7
Final simplification9.0
herbie shell --seed 2019195
(FPCore (a b c)
:name "The quadratic formula (r2)"
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))