\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.5253865352374434 \cdot 10^{-276}:\\
\;\;\;\;-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 5.072204432072848 \cdot 10^{+95}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\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.5253865352374434e-276)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 5.072204432072848e+95)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(* -0.5 (/ (+ b b) a)))))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.5253865352374434e-276) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 5.072204432072848e+95) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (a * 2.0);
} else {
tmp = -0.5 * ((b + b) / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.8 |
|---|---|
| Target | 21.0 |
| Herbie | 13.1 |
if b < 1.5253865352374434e-276Initial program 43.2
Simplified43.2
rmApplied flip-+_binary64_39343.3
Simplified22.9
rmApplied *-un-lft-identity_binary64_41922.9
Applied *-un-lft-identity_binary64_41922.9
Applied times-frac_binary64_42522.9
Applied times-frac_binary64_42522.9
Simplified22.9
Simplified17.8
if 1.5253865352374434e-276 < b < 5.0722044320728483e95Initial program 8.4
if 5.0722044320728483e95 < b Initial program 45.1
Simplified45.2
Taylor expanded around 0 5.1
Final simplification13.1
herbie shell --seed 2020344
(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)))