\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.2801399473597744 \cdot 10^{+138}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2.753759009350666 \cdot 10^{-76}:\\
\;\;\;\;-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 1.0822587973346299 \cdot 10^{+133}:\\
\;\;\;\;-0.5 \cdot \left(\left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \cdot \frac{1}{a}\right)\\
\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.2801399473597744e+138)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 2.753759009350666e-76)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.0822587973346299e+133)
(* -0.5 (* (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) (/ 1.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.2801399473597744e+138) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 2.753759009350666e-76) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.0822587973346299e+133) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) * (1.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 | 33.8 |
|---|---|
| Target | 20.7 |
| Herbie | 7.6 |
if b < -1.2801399473597744e138Initial program 62.5
Simplified62.5
Taylor expanded around -inf 1.5
if -1.2801399473597744e138 < b < 2.7537590093506661e-76Initial program 27.6
Simplified27.6
rmApplied flip-+_binary6429.8
Simplified17.0
rmApplied *-un-lft-identity_binary6417.0
Applied *-un-lft-identity_binary6417.0
Applied times-frac_binary6417.0
Applied times-frac_binary6417.0
Simplified17.0
Simplified11.5
if 2.7537590093506661e-76 < b < 1.0822587973346299e133Initial program 5.3
Simplified5.3
rmApplied div-inv_binary645.5
if 1.0822587973346299e133 < b Initial program 56.3
Simplified56.3
Taylor expanded around inf 3.8
Simplified3.8
Final simplification7.6
herbie shell --seed 2020275
(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)))