\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.3091834909018501 \cdot 10^{+152}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.4031237401242977 \cdot 10^{-270}:\\
\;\;\;\;-0.5 \cdot \left(4 \cdot \left(c \cdot \frac{1}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\right)\right)\\
\mathbf{elif}\;b \leq 2.1578323955249213 \cdot 10^{+116}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b \cdot 2}{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.3091834909018501e+152)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 1.4031237401242977e-270)
(* -0.5 (* 4.0 (* c (/ 1.0 (- b (sqrt (- (* b b) (* 4.0 (* c a)))))))))
(if (<= b 2.1578323955249213e+116)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(* -0.5 (/ (* b 2.0) 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.3091834909018501e+152) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 1.4031237401242977e-270) {
tmp = -0.5 * (4.0 * (c * (1.0 / (b - sqrt((b * b) - (4.0 * (c * a)))))));
} else if (b <= 2.1578323955249213e+116) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = -0.5 * ((b * 2.0) / a);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 21.5 |
| Herbie | 6.5 |
if b < -1.30918349090185012e152Initial program 63.9
Simplified63.9
Taylor expanded around -inf 1.6
if -1.30918349090185012e152 < b < 1.4031237401242977e-270Initial program 33.8
Simplified33.8
rmApplied flip-+_binary64_72533.8
Simplified16.2
rmApplied *-un-lft-identity_binary64_75116.2
Applied *-un-lft-identity_binary64_75116.2
Applied times-frac_binary64_75716.2
Applied times-frac_binary64_75716.2
Simplified16.2
Simplified8.7
rmApplied div-inv_binary64_7488.8
if 1.4031237401242977e-270 < b < 2.1578323955249213e116Initial program 8.2
Simplified8.2
if 2.1578323955249213e116 < b Initial program 50.8
Simplified50.8
rmApplied flip-+_binary64_72563.6
Simplified62.6
Taylor expanded around 0 3.3
Simplified3.3
Final simplification6.5
herbie shell --seed 2020292
(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)))