\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 -2.049220194580872 \cdot 10^{+133}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := 4 \cdot \left(c \cdot a\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -2.2556714692887474 \cdot 10^{-119}:\\
\;\;\;\;\frac{t_0 \cdot \frac{0.5}{a}}{t_1 - b}\\
\mathbf{elif}\;b \leq 2.4148286761692006 \cdot 10^{+24}:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\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 -2.049220194580872e+133)
(- (/ c b))
(let* ((t_0 (* 4.0 (* c a))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= b -2.2556714692887474e-119)
(/ (* t_0 (/ 0.5 a)) (- t_1 b))
(if (<= b 2.4148286761692006e+24)
(/ (- (- b) t_1) (* a 2.0))
(/ (- 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 <= -2.049220194580872e+133) {
tmp = -(c / b);
} else {
double t_0 = 4.0 * (c * a);
double t_1 = sqrt((b * b) - t_0);
double tmp_1;
if (b <= -2.2556714692887474e-119) {
tmp_1 = (t_0 * (0.5 / a)) / (t_1 - b);
} else if (b <= 2.4148286761692006e+24) {
tmp_1 = (-b - t_1) / (a * 2.0);
} else {
tmp_1 = -b / a;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.9 |
|---|---|
| Target | 21.2 |
| Herbie | 9.6 |
if b < -2.0492201945808721e133Initial program 62.3
Taylor expanded in b around -inf 1.6
Simplified1.6
if -2.0492201945808721e133 < b < -2.2556714692887474e-119Initial program 40.4
Applied div-inv_binary6440.4
Simplified40.4
Applied flip--_binary6440.4
Applied associate-*l/_binary6440.5
Simplified12.9
if -2.2556714692887474e-119 < b < 2.4148286761692006e24Initial program 13.4
Applied *-un-lft-identity_binary6413.4
Applied cancel-sign-sub-inv_binary6413.4
if 2.4148286761692006e24 < b Initial program 35.2
Taylor expanded in b around inf 7.1
Final simplification9.6
herbie shell --seed 2022081
(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)))