\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 -8.997482647396267 \cdot 10^{+153}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.9618900815942973 \cdot 10^{-188}:\\
\;\;\;\;-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 3.687480246729245 \cdot 10^{+60}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a}\\
\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 -8.997482647396267e+153)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 1.9618900815942973e-188)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 3.687480246729245e+60)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) 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 <= -8.997482647396267e+153) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 1.9618900815942973e-188) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 3.687480246729245e+60) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / 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 | 34.4 |
|---|---|
| Target | 20.8 |
| Herbie | 6.8 |
if b < -8.9974826473962671e153Initial program 64.0
Simplified64.0
Taylor expanded around -inf 0.9
if -8.9974826473962671e153 < b < 1.9618900815942973e-188Initial program 32.0
Simplified32.0
rmApplied flip-+_binary6432.1
Simplified16.2
rmApplied *-un-lft-identity_binary6416.2
Applied *-un-lft-identity_binary6416.2
Applied times-frac_binary6416.2
Applied times-frac_binary6416.2
Simplified16.2
Simplified9.8
if 1.9618900815942973e-188 < b < 3.6874802467292453e60Initial program 6.8
Simplified6.8
rmApplied *-un-lft-identity_binary646.8
if 3.6874802467292453e60 < b Initial program 40.3
Simplified40.3
Taylor expanded around inf 5.1
Simplified5.1
Final simplification6.8
herbie shell --seed 2021174
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
: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)))