\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.6751224960373033 \cdot 10^{+149}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -7.506137588580103 \cdot 10^{-277}:\\
\;\;\;\;-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 6.199083478586426 \cdot 10^{+140}:\\
\;\;\;\;-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.6751224960373033e+149)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -7.506137588580103e-277)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 6.199083478586426e+140)
(* -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.6751224960373033e+149) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -7.506137588580103e-277) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 6.199083478586426e+140) {
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.1 |
|---|---|
| Target | 21.3 |
| Herbie | 6.5 |
if b < -1.6751224960373033e149Initial program 63.6
Simplified63.6
Taylor expanded around -inf 1.4
if -1.6751224960373033e149 < b < -7.5061375885801029e-277Initial program 35.8
Simplified35.8
rmApplied flip-+_binary6435.8
Simplified16.3
rmApplied *-un-lft-identity_binary6416.3
Applied *-un-lft-identity_binary6416.3
Applied times-frac_binary6416.4
Applied times-frac_binary6416.4
Simplified16.4
Simplified7.8
if -7.5061375885801029e-277 < b < 6.19908347858642586e140Initial program 9.1
Simplified9.1
if 6.19908347858642586e140 < b Initial program 58.4
Simplified58.4
Taylor expanded around inf 2.9
Simplified2.9
Final simplification6.5
herbie shell --seed 2020220
(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)))