\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 -5.188391915920029 \cdot 10^{+118}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 3.4760502493091374 \cdot 10^{-304}:\\
\;\;\;\;-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.1520730840908697 \cdot 10^{+108}:\\
\;\;\;\;\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 \frac{b}{a}\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 -5.188391915920029e+118)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 3.4760502493091374e-304)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 4.1520730840908697e+108)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* 2.0 a))
(* -0.5 (* 2.0 (/ 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 <= -5.188391915920029e+118) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 3.4760502493091374e-304) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 4.1520730840908697e+108) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (2.0 * a);
} else {
tmp = -0.5 * (2.0 * (b / a));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.9 |
|---|---|
| Target | 21.5 |
| Herbie | 6.4 |
if b < -5.18839191592002921e118Initial program 61.1
Simplified61.1
Taylor expanded around -inf 2.1
if -5.18839191592002921e118 < b < 3.4760502493091374e-304Initial program 33.1
Simplified33.1
rmApplied flip-+_binary64_107533.1
Simplified16.0
rmApplied *-un-lft-identity_binary64_110116.0
Applied *-un-lft-identity_binary64_110116.0
Applied times-frac_binary64_110716.0
Applied times-frac_binary64_110716.0
Simplified16.0
Simplified8.5
if 3.4760502493091374e-304 < b < 4.15207308409086968e108Initial program 8.9
if 4.15207308409086968e108 < b Initial program 49.8
Simplified49.8
Taylor expanded around inf 3.4
Final simplification6.4
herbie shell --seed 2021011
(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)))