\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.297522851756149307625287590446857172218 \cdot 10^{130}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -7.499564665356541230478133000064554936556 \cdot 10^{-290}:\\
\;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\
\mathbf{elif}\;b \le 2.043334298601044940502096480059938459672 \cdot 10^{53}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{4}{\frac{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(-2 \cdot \frac{c}{b}\right)\\
\end{array}double f(double a, double b, double c) {
double r75088 = b;
double r75089 = -r75088;
double r75090 = r75088 * r75088;
double r75091 = 4.0;
double r75092 = a;
double r75093 = r75091 * r75092;
double r75094 = c;
double r75095 = r75093 * r75094;
double r75096 = r75090 - r75095;
double r75097 = sqrt(r75096);
double r75098 = r75089 + r75097;
double r75099 = 2.0;
double r75100 = r75099 * r75092;
double r75101 = r75098 / r75100;
return r75101;
}
double f(double a, double b, double c) {
double r75102 = b;
double r75103 = -4.2975228517561493e+130;
bool r75104 = r75102 <= r75103;
double r75105 = 1.0;
double r75106 = c;
double r75107 = r75106 / r75102;
double r75108 = a;
double r75109 = r75102 / r75108;
double r75110 = r75107 - r75109;
double r75111 = r75105 * r75110;
double r75112 = -7.499564665356541e-290;
bool r75113 = r75102 <= r75112;
double r75114 = -r75102;
double r75115 = r75102 * r75102;
double r75116 = 4.0;
double r75117 = r75116 * r75108;
double r75118 = r75117 * r75106;
double r75119 = r75115 - r75118;
double r75120 = sqrt(r75119);
double r75121 = r75114 + r75120;
double r75122 = 1.0;
double r75123 = 2.0;
double r75124 = r75123 * r75108;
double r75125 = r75122 / r75124;
double r75126 = r75121 * r75125;
double r75127 = 2.043334298601045e+53;
bool r75128 = r75102 <= r75127;
double r75129 = r75122 / r75123;
double r75130 = r75114 - r75120;
double r75131 = r75122 * r75130;
double r75132 = r75131 / r75106;
double r75133 = r75116 / r75132;
double r75134 = r75129 * r75133;
double r75135 = -2.0;
double r75136 = r75135 * r75107;
double r75137 = r75129 * r75136;
double r75138 = r75128 ? r75134 : r75137;
double r75139 = r75113 ? r75126 : r75138;
double r75140 = r75104 ? r75111 : r75139;
return r75140;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 20.6 |
| Herbie | 7.0 |
if b < -4.2975228517561493e+130Initial program 54.6
Taylor expanded around -inf 2.8
Simplified2.8
if -4.2975228517561493e+130 < b < -7.499564665356541e-290Initial program 9.2
rmApplied div-inv9.4
if -7.499564665356541e-290 < b < 2.043334298601045e+53Initial program 29.9
rmApplied flip-+30.0
Simplified16.3
rmApplied *-un-lft-identity16.3
Applied *-un-lft-identity16.3
Applied times-frac16.3
Applied times-frac16.3
Simplified16.3
Simplified21.7
rmApplied associate-/l*21.8
Simplified9.0
if 2.043334298601045e+53 < b Initial program 57.4
rmApplied flip-+57.4
Simplified29.4
rmApplied *-un-lft-identity29.4
Applied *-un-lft-identity29.4
Applied times-frac29.4
Applied times-frac29.4
Simplified29.4
Simplified29.0
rmApplied associate-/l*29.1
Simplified26.3
Taylor expanded around inf 4.1
Final simplification7.0
herbie shell --seed 2019362
(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)))