\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.8546541145634366 \cdot 10^{+136}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -1.8441922009769164 \cdot 10^{-242}:\\
\;\;\;\;-0.5 \cdot \left(4 \cdot \frac{c}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\right)\\
\mathbf{elif}\;b \leq 4.65745276732901 \cdot 10^{+47}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot 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.8546541145634366e+136)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -1.8441922009769164e-242)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 4.65745276732901e+47)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* 2.0 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.8546541145634366e+136) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -1.8441922009769164e-242) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 4.65745276732901e+47) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (2.0 * 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.0 |
|---|---|
| Target | 20.7 |
| Herbie | 6.8 |
if b < -1.8546541145634366e136Initial program 62.0
Simplified62.0
Taylor expanded around -inf 1.8
if -1.8546541145634366e136 < b < -1.84419220097691638e-242Initial program 36.2
Simplified36.2
rmApplied flip-+_binary64_39336.3
Simplified15.7
rmApplied *-un-lft-identity_binary64_41915.7
Applied *-un-lft-identity_binary64_41915.7
Applied times-frac_binary64_42515.7
Applied times-frac_binary64_42515.7
Simplified15.7
Simplified6.9
if -1.84419220097691638e-242 < b < 4.6574527673290098e47Initial program 10.8
if 4.6574527673290098e47 < b Initial program 36.9
Simplified36.9
Taylor expanded around inf 5.8
Simplified5.8
Final simplification6.8
herbie shell --seed 2020349
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected #f
: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)))