\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 -9.139254247068609 \cdot 10^{+140}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \le 9.931313556234952 \cdot 10^{-296}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a} \cdot \frac{1}{2}\\
\mathbf{elif}\;b \le 6.523631550102089 \cdot 10^{+89}:\\
\;\;\;\;\frac{c \cdot -2}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r27712794 = b;
double r27712795 = -r27712794;
double r27712796 = r27712794 * r27712794;
double r27712797 = 4.0;
double r27712798 = a;
double r27712799 = r27712797 * r27712798;
double r27712800 = c;
double r27712801 = r27712799 * r27712800;
double r27712802 = r27712796 - r27712801;
double r27712803 = sqrt(r27712802);
double r27712804 = r27712795 + r27712803;
double r27712805 = 2.0;
double r27712806 = r27712805 * r27712798;
double r27712807 = r27712804 / r27712806;
return r27712807;
}
double f(double a, double b, double c) {
double r27712808 = b;
double r27712809 = -9.139254247068609e+140;
bool r27712810 = r27712808 <= r27712809;
double r27712811 = c;
double r27712812 = r27712811 / r27712808;
double r27712813 = a;
double r27712814 = r27712808 / r27712813;
double r27712815 = r27712812 - r27712814;
double r27712816 = 9.931313556234952e-296;
bool r27712817 = r27712808 <= r27712816;
double r27712818 = r27712808 * r27712808;
double r27712819 = r27712811 * r27712813;
double r27712820 = 4.0;
double r27712821 = r27712819 * r27712820;
double r27712822 = r27712818 - r27712821;
double r27712823 = sqrt(r27712822);
double r27712824 = r27712823 - r27712808;
double r27712825 = r27712824 / r27712813;
double r27712826 = 0.5;
double r27712827 = r27712825 * r27712826;
double r27712828 = 6.523631550102089e+89;
bool r27712829 = r27712808 <= r27712828;
double r27712830 = -2.0;
double r27712831 = r27712811 * r27712830;
double r27712832 = r27712823 + r27712808;
double r27712833 = r27712831 / r27712832;
double r27712834 = -r27712812;
double r27712835 = r27712829 ? r27712833 : r27712834;
double r27712836 = r27712817 ? r27712827 : r27712835;
double r27712837 = r27712810 ? r27712815 : r27712836;
return r27712837;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.0 |
|---|---|
| Target | 20.1 |
| Herbie | 6.6 |
if b < -9.139254247068609e+140Initial program 55.8
Simplified55.8
Taylor expanded around -inf 1.6
if -9.139254247068609e+140 < b < 9.931313556234952e-296Initial program 8.7
Simplified8.7
rmApplied *-un-lft-identity8.7
Applied *-un-lft-identity8.7
Applied distribute-lft-out--8.7
Applied associate-/l*8.9
rmApplied *-un-lft-identity8.9
Applied times-frac8.8
Applied add-sqr-sqrt8.8
Applied times-frac8.8
Simplified8.8
Simplified8.7
if 9.931313556234952e-296 < b < 6.523631550102089e+89Initial program 32.6
Simplified32.6
rmApplied *-un-lft-identity32.6
Applied *-un-lft-identity32.6
Applied distribute-lft-out--32.6
Applied associate-/l*32.6
rmApplied flip--32.7
Applied associate-/r/32.8
Applied *-un-lft-identity32.8
Applied times-frac32.8
Simplified16.4
Taylor expanded around inf 9.3
rmApplied un-div-inv9.2
if 6.523631550102089e+89 < b Initial program 58.7
Simplified58.7
Taylor expanded around inf 2.6
Simplified2.6
Final simplification6.6
herbie shell --seed 2019112
(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)))