\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 -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\
\mathbf{elif}\;b \le 2.071930020515770918527743961403466592109 \cdot 10^{-74}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r84651 = b;
double r84652 = -r84651;
double r84653 = r84651 * r84651;
double r84654 = 4.0;
double r84655 = a;
double r84656 = r84654 * r84655;
double r84657 = c;
double r84658 = r84656 * r84657;
double r84659 = r84653 - r84658;
double r84660 = sqrt(r84659);
double r84661 = r84652 + r84660;
double r84662 = 2.0;
double r84663 = r84662 * r84655;
double r84664 = r84661 / r84663;
return r84664;
}
double f(double a, double b, double c) {
double r84665 = b;
double r84666 = -4.919628179067154e+153;
bool r84667 = r84665 <= r84666;
double r84668 = c;
double r84669 = r84668 / r84665;
double r84670 = a;
double r84671 = r84665 / r84670;
double r84672 = r84669 - r84671;
double r84673 = 1.0;
double r84674 = r84672 * r84673;
double r84675 = 2.071930020515771e-74;
bool r84676 = r84665 <= r84675;
double r84677 = r84665 * r84665;
double r84678 = 4.0;
double r84679 = r84678 * r84670;
double r84680 = r84679 * r84668;
double r84681 = r84677 - r84680;
double r84682 = sqrt(r84681);
double r84683 = r84682 - r84665;
double r84684 = 2.0;
double r84685 = r84684 * r84670;
double r84686 = r84683 / r84685;
double r84687 = -1.0;
double r84688 = r84687 * r84669;
double r84689 = r84676 ? r84686 : r84688;
double r84690 = r84667 ? r84674 : r84689;
return r84690;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.8 |
|---|---|
| Target | 20.4 |
| Herbie | 10.3 |
if b < -4.919628179067154e+153Initial program 63.8
Simplified63.8
rmApplied clear-num63.8
rmApplied *-un-lft-identity63.8
Applied add-cube-cbrt63.8
Applied times-frac63.8
Simplified63.8
Simplified63.8
rmApplied *-un-lft-identity63.8
Applied associate-*l*63.8
Simplified63.8
Taylor expanded around -inf 2.1
Simplified2.1
if -4.919628179067154e+153 < b < 2.071930020515771e-74Initial program 12.8
Simplified12.8
rmApplied clear-num13.0
rmApplied *-un-lft-identity13.0
Applied add-cube-cbrt13.0
Applied times-frac13.0
Simplified13.0
Simplified12.9
rmApplied *-un-lft-identity12.9
Applied associate-*l*12.9
Simplified12.8
if 2.071930020515771e-74 < b Initial program 53.2
Simplified53.2
rmApplied clear-num53.2
rmApplied *-un-lft-identity53.2
Applied add-cube-cbrt53.2
Applied times-frac53.2
Simplified53.2
Simplified53.2
rmApplied *-un-lft-identity53.2
Applied associate-*l*53.2
Simplified53.2
Taylor expanded around inf 9.2
Final simplification10.3
herbie shell --seed 2019208
(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)))