\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 -9.296819166068998 \cdot 10^{+40}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2.278112172640853 \cdot 10^{-203}:\\
\;\;\;\;-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.2904769892397663 \cdot 10^{+98}:\\
\;\;\;\;-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 \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 -9.296819166068998e+40)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 2.278112172640853e-203)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.2904769892397663e+98)
(* -0.5 (* (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) (/ 1.0 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 <= -9.296819166068998e+40) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 2.278112172640853e-203) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.2904769892397663e+98) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) * (1.0 / 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 | 33.0 |
|---|---|
| Target | 20.5 |
| Herbie | 7.0 |
if b < -9.29681916606899789e40Initial program 57.1
Simplified57.1
Taylor expanded around -inf 4.3
if -9.29681916606899789e40 < b < 2.278112172640853e-203Initial program 23.9
Simplified23.9
rmApplied flip-+_binary6424.1
Simplified14.9
rmApplied *-un-lft-identity_binary6414.9
Applied *-un-lft-identity_binary6414.9
Applied times-frac_binary6414.9
Applied times-frac_binary6414.9
Simplified14.9
Simplified10.4
if 2.278112172640853e-203 < b < 1.2904769892397663e98Initial program 7.3
Simplified7.3
rmApplied div-inv_binary647.5
if 1.2904769892397663e98 < b Initial program 45.6
Simplified45.6
rmApplied flip-+_binary6463.2
Simplified62.3
Taylor expanded around 0 4.2
Simplified4.2
Final simplification7.0
herbie shell --seed 2020270
(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)))