\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.5124621562905613 \cdot 10^{+151}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.5126179102014787 \cdot 10^{-251}:\\
\;\;\;\;-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.8042819818410436 \cdot 10^{+25}:\\
\;\;\;\;-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 -1.5124621562905613e+151)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 1.5126179102014787e-251)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.8042819818410436e+25)
(* -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 <= -1.5124621562905613e+151) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 1.5126179102014787e-251) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.8042819818410436e+25) {
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.0 |
|---|---|
| Target | 21.2 |
| Herbie | 6.9 |
if b < -1.5124621562905613e151Initial program 63.9
Simplified63.9
Taylor expanded around -inf 1.6
if -1.5124621562905613e151 < b < 1.5126179102014787e-251Initial program 32.8
Simplified32.8
rmApplied flip-+_binary64_107532.9
Simplified16.0
rmApplied *-un-lft-identity_binary64_110116.0
Applied *-un-lft-identity_binary64_110116.0
Applied times-frac_binary64_110716.0
Applied times-frac_binary64_110716.0
Simplified16.0
Simplified8.7
if 1.5126179102014787e-251 < b < 1.8042819818410436e25Initial program 9.4
Simplified9.4
if 1.8042819818410436e25 < b Initial program 34.8
Simplified34.8
Taylor expanded around inf 5.7
Simplified5.7
Final simplification6.9
herbie shell --seed 2021019
(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)))