\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 -3.263941314600607 \cdot 10^{+152}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \le -4.687918346756617 \cdot 10^{-254}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a} \cdot \frac{1}{2}\\
\mathbf{elif}\;b \le 3.463606471108268 \cdot 10^{+121}:\\
\;\;\;\;\frac{c \cdot -2}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + b}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r20365603 = b;
double r20365604 = -r20365603;
double r20365605 = r20365603 * r20365603;
double r20365606 = 4.0;
double r20365607 = a;
double r20365608 = r20365606 * r20365607;
double r20365609 = c;
double r20365610 = r20365608 * r20365609;
double r20365611 = r20365605 - r20365610;
double r20365612 = sqrt(r20365611);
double r20365613 = r20365604 + r20365612;
double r20365614 = 2.0;
double r20365615 = r20365614 * r20365607;
double r20365616 = r20365613 / r20365615;
return r20365616;
}
double f(double a, double b, double c) {
double r20365617 = b;
double r20365618 = -3.263941314600607e+152;
bool r20365619 = r20365617 <= r20365618;
double r20365620 = c;
double r20365621 = r20365620 / r20365617;
double r20365622 = a;
double r20365623 = r20365617 / r20365622;
double r20365624 = r20365621 - r20365623;
double r20365625 = -4.687918346756617e-254;
bool r20365626 = r20365617 <= r20365625;
double r20365627 = r20365617 * r20365617;
double r20365628 = 4.0;
double r20365629 = r20365620 * r20365622;
double r20365630 = r20365628 * r20365629;
double r20365631 = r20365627 - r20365630;
double r20365632 = sqrt(r20365631);
double r20365633 = r20365632 - r20365617;
double r20365634 = r20365633 / r20365622;
double r20365635 = 0.5;
double r20365636 = r20365634 * r20365635;
double r20365637 = 3.463606471108268e+121;
bool r20365638 = r20365617 <= r20365637;
double r20365639 = -2.0;
double r20365640 = r20365620 * r20365639;
double r20365641 = r20365632 + r20365617;
double r20365642 = r20365640 / r20365641;
double r20365643 = -r20365621;
double r20365644 = r20365638 ? r20365642 : r20365643;
double r20365645 = r20365626 ? r20365636 : r20365644;
double r20365646 = r20365619 ? r20365624 : r20365645;
return r20365646;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.3 |
|---|---|
| Target | 20.3 |
| Herbie | 6.4 |
if b < -3.263941314600607e+152Initial program 60.1
Simplified60.1
Taylor expanded around -inf 2.3
if -3.263941314600607e+152 < b < -4.687918346756617e-254Initial program 7.8
Simplified7.8
rmApplied clear-num8.0
rmApplied *-un-lft-identity8.0
Applied *-un-lft-identity8.0
Applied distribute-lft-out--8.0
Applied times-frac8.0
Applied *-un-lft-identity8.0
Applied times-frac8.0
Simplified8.0
Simplified7.8
if -4.687918346756617e-254 < b < 3.463606471108268e+121Initial program 31.6
Simplified31.6
rmApplied clear-num31.7
rmApplied flip--31.8
Applied associate-/r/31.9
Applied associate-/r*31.9
Simplified14.4
Taylor expanded around 0 8.7
if 3.463606471108268e+121 < b Initial program 59.8
Simplified59.8
rmApplied div-inv59.8
Simplified59.8
Taylor expanded around inf 2.3
Simplified2.3
Final simplification6.4
herbie shell --seed 2019128
(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)))