\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.4220016328491612 \cdot 10^{+151}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 5.126982040291221 \cdot 10^{-283}:\\
\;\;\;\;-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 2.1353619288367854 \cdot 10^{+148}:\\
\;\;\;\;-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(4 \cdot \left(0.5 \cdot \frac{b}{a}\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.4220016328491612e+151)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 5.126982040291221e-283)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 2.1353619288367854e+148)
(* -0.5 (* (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) (/ 1.0 a)))
(* -0.5 (* 4.0 (* 0.5 (/ 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.4220016328491612e+151) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 5.126982040291221e-283) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 2.1353619288367854e+148) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) * (1.0 / a));
} else {
tmp = -0.5 * (4.0 * (0.5 * (b / a)));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.5 |
|---|---|
| Target | 20.4 |
| Herbie | 6.5 |
if b < -1.42200163284916121e151Initial program 63.7
Simplified63.7
Taylor expanded around -inf 1.4
if -1.42200163284916121e151 < b < 5.12698204029122054e-283Initial program 33.9
Simplified33.9
rmApplied flip-+_binary64_38833.9
Simplified15.7
rmApplied *-un-lft-identity_binary64_41415.7
Applied *-un-lft-identity_binary64_41415.7
Applied times-frac_binary64_42015.7
Applied times-frac_binary64_42015.7
Simplified15.7
Simplified8.5
if 5.12698204029122054e-283 < b < 2.13536192883678537e148Initial program 7.9
Simplified7.9
rmApplied div-inv_binary64_4118.1
if 2.13536192883678537e148 < b Initial program 61.3
Simplified61.3
rmApplied flip-+_binary64_38864.0
Simplified62.8
rmApplied *-un-lft-identity_binary64_41462.8
Applied *-un-lft-identity_binary64_41462.8
Applied times-frac_binary64_42062.8
Applied times-frac_binary64_42062.8
Simplified62.8
Simplified62.5
Taylor expanded around 0 3.2
Final simplification6.5
herbie shell --seed 2020346
(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)))