\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \leq -1.0312054881735746 \cdot 10^{+106}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.061124783334026 \cdot 10^{-248}:\\
\;\;\;\;-0.5 \cdot \frac{4}{\frac{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{c}}\\
\mathbf{elif}\;b \leq 3.89202438398013 \cdot 10^{+65}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \left(\frac{b}{a} - \frac{c}{b}\right)\right)\\
\end{array}(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(if (<= b -1.0312054881735746e+106)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 1.061124783334026e-248)
(* -0.5 (/ 4.0 (/ (- b (sqrt (- (* b b) (* 4.0 (* c a))))) c)))
(if (<= b 3.89202438398013e+65)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(* -0.5 (* 2.0 (- (/ b a) (/ c b))))))))double code(double a, double b, double c) {
return (-b - sqrt((b * b) - (4.0 * (a * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
double tmp;
if (b <= -1.0312054881735746e+106) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 1.061124783334026e-248) {
tmp = -0.5 * (4.0 / ((b - sqrt((b * b) - (4.0 * (c * a)))) / c));
} else if (b <= 3.89202438398013e+65) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = -0.5 * (2.0 * ((b / a) - (c / b)));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.6 |
|---|---|
| Target | 21.7 |
| Herbie | 7.0 |
if b < -1.03120548817357458e106Initial program 60.0
Simplified60.0
Taylor expanded around -inf 2.7
if -1.03120548817357458e106 < b < 1.06112478333402608e-248Initial program 31.7
Simplified31.7
rmApplied flip-+_binary64_73431.7
Simplified17.0
rmApplied *-un-lft-identity_binary64_76017.0
Applied *-un-lft-identity_binary64_76017.0
Applied times-frac_binary64_76617.0
Simplified17.0
Simplified10.0
if 1.06112478333402608e-248 < b < 3.89202438398013009e65Initial program 9.3
Simplified9.3
if 3.89202438398013009e65 < b Initial program 40.9
Simplified40.9
Taylor expanded around inf 4.2
Simplified4.2
Final simplification7.0
herbie shell --seed 2021046
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))