\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 -2.615257373542238721197930661559276546696 \cdot 10^{153}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 1.388070047225937856958905133202240499626 \cdot 10^{-143}:\\
\;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r172620 = b;
double r172621 = -r172620;
double r172622 = r172620 * r172620;
double r172623 = 4.0;
double r172624 = a;
double r172625 = r172623 * r172624;
double r172626 = c;
double r172627 = r172625 * r172626;
double r172628 = r172622 - r172627;
double r172629 = sqrt(r172628);
double r172630 = r172621 + r172629;
double r172631 = 2.0;
double r172632 = r172631 * r172624;
double r172633 = r172630 / r172632;
return r172633;
}
double f(double a, double b, double c) {
double r172634 = b;
double r172635 = -2.6152573735422387e+153;
bool r172636 = r172634 <= r172635;
double r172637 = 1.0;
double r172638 = c;
double r172639 = r172638 / r172634;
double r172640 = a;
double r172641 = r172634 / r172640;
double r172642 = r172639 - r172641;
double r172643 = r172637 * r172642;
double r172644 = 1.3880700472259379e-143;
bool r172645 = r172634 <= r172644;
double r172646 = 2.0;
double r172647 = pow(r172634, r172646);
double r172648 = 4.0;
double r172649 = r172640 * r172638;
double r172650 = r172648 * r172649;
double r172651 = r172647 - r172650;
double r172652 = sqrt(r172651);
double r172653 = r172652 - r172634;
double r172654 = 2.0;
double r172655 = r172640 * r172654;
double r172656 = r172653 / r172655;
double r172657 = -1.0;
double r172658 = r172657 * r172639;
double r172659 = r172645 ? r172656 : r172658;
double r172660 = r172636 ? r172643 : r172659;
return r172660;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.5 |
|---|---|
| Target | 21.5 |
| Herbie | 10.9 |
if b < -2.6152573735422387e+153Initial program 63.8
rmApplied clear-num63.8
Simplified63.8
rmApplied *-un-lft-identity63.8
Applied add-cube-cbrt63.8
Applied times-frac63.8
Simplified63.8
Simplified63.8
Taylor expanded around -inf 2.1
Simplified2.1
if -2.6152573735422387e+153 < b < 1.3880700472259379e-143Initial program 11.5
rmApplied clear-num11.6
Simplified11.6
rmApplied *-un-lft-identity11.6
Applied add-cube-cbrt11.6
Applied times-frac11.6
Simplified11.6
Simplified11.5
if 1.3880700472259379e-143 < b Initial program 50.3
rmApplied clear-num50.3
Simplified50.3
rmApplied *-un-lft-identity50.3
Applied add-cube-cbrt50.3
Applied times-frac50.3
Simplified50.3
Simplified50.3
Taylor expanded around inf 12.6
Final simplification10.9
herbie shell --seed 2019351 +o rules:numerics
(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)))