\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.3798449810939068 \cdot 10^{+76}:\\
\;\;\;\;\frac{\frac{\left(\frac{c}{\frac{b}{a}} - b\right) \cdot 2}{a}}{2}\\
\mathbf{elif}\;b \le 2.051368100893223 \cdot 10^{-286}:\\
\;\;\;\;\frac{\frac{\sqrt{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}}{\frac{a}{\sqrt{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}}}}{2}\\
\mathbf{elif}\;b \le 1.2859619246531207 \cdot 10^{+138}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\mathsf{fma}\left(a, -4 \cdot c, b \cdot b\right)} + b} \cdot \left(-4 \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-4 \cdot c}{2 \cdot b}}{2}\\
\end{array}double f(double a, double b, double c) {
double r3897295 = b;
double r3897296 = -r3897295;
double r3897297 = r3897295 * r3897295;
double r3897298 = 4.0;
double r3897299 = a;
double r3897300 = r3897298 * r3897299;
double r3897301 = c;
double r3897302 = r3897300 * r3897301;
double r3897303 = r3897297 - r3897302;
double r3897304 = sqrt(r3897303);
double r3897305 = r3897296 + r3897304;
double r3897306 = 2.0;
double r3897307 = r3897306 * r3897299;
double r3897308 = r3897305 / r3897307;
return r3897308;
}
double f(double a, double b, double c) {
double r3897309 = b;
double r3897310 = -1.3798449810939068e+76;
bool r3897311 = r3897309 <= r3897310;
double r3897312 = c;
double r3897313 = a;
double r3897314 = r3897309 / r3897313;
double r3897315 = r3897312 / r3897314;
double r3897316 = r3897315 - r3897309;
double r3897317 = 2.0;
double r3897318 = r3897316 * r3897317;
double r3897319 = r3897318 / r3897313;
double r3897320 = r3897319 / r3897317;
double r3897321 = 2.051368100893223e-286;
bool r3897322 = r3897309 <= r3897321;
double r3897323 = -4.0;
double r3897324 = r3897323 * r3897312;
double r3897325 = r3897309 * r3897309;
double r3897326 = fma(r3897324, r3897313, r3897325);
double r3897327 = sqrt(r3897326);
double r3897328 = r3897327 - r3897309;
double r3897329 = sqrt(r3897328);
double r3897330 = r3897313 / r3897329;
double r3897331 = r3897329 / r3897330;
double r3897332 = r3897331 / r3897317;
double r3897333 = 1.2859619246531207e+138;
bool r3897334 = r3897309 <= r3897333;
double r3897335 = 0.5;
double r3897336 = fma(r3897313, r3897324, r3897325);
double r3897337 = sqrt(r3897336);
double r3897338 = r3897337 + r3897309;
double r3897339 = r3897335 / r3897338;
double r3897340 = r3897339 * r3897324;
double r3897341 = r3897317 * r3897309;
double r3897342 = r3897324 / r3897341;
double r3897343 = r3897342 / r3897317;
double r3897344 = r3897334 ? r3897340 : r3897343;
double r3897345 = r3897322 ? r3897332 : r3897344;
double r3897346 = r3897311 ? r3897320 : r3897345;
return r3897346;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.2 |
|---|---|
| Target | 20.2 |
| Herbie | 6.7 |
if b < -1.3798449810939068e+76Initial program 39.5
Simplified39.5
Taylor expanded around -inf 9.8
Simplified4.4
if -1.3798449810939068e+76 < b < 2.051368100893223e-286Initial program 9.0
Simplified9.0
Taylor expanded around 0 8.9
Simplified8.9
rmApplied add-sqr-sqrt9.2
Applied associate-/l*9.2
if 2.051368100893223e-286 < b < 1.2859619246531207e+138Initial program 34.9
Simplified34.8
Taylor expanded around 0 34.8
Simplified34.9
rmApplied flip--35.0
Simplified16.5
rmApplied *-un-lft-identity16.5
Applied *-un-lft-identity16.5
Applied distribute-lft-out16.5
Applied times-frac15.7
Applied associate-/l*10.9
Simplified8.3
rmApplied *-un-lft-identity8.3
Applied *-un-lft-identity8.3
Applied *-un-lft-identity8.3
Applied distribute-lft-out8.3
Applied div-inv8.3
Applied times-frac8.4
Applied times-frac8.4
Simplified8.4
Simplified8.4
if 1.2859619246531207e+138 < b Initial program 61.2
Simplified61.2
Taylor expanded around 0 61.2
Simplified61.2
rmApplied flip--61.2
Simplified35.1
rmApplied *-un-lft-identity35.1
Applied *-un-lft-identity35.1
Applied distribute-lft-out35.1
Applied times-frac35.4
Applied associate-/l*35.2
Simplified34.0
Taylor expanded around 0 1.8
Final simplification6.7
herbie shell --seed 2019143 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r1)"
:herbie-target
(if (< b 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)))