\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.1345533515695916 \cdot 10^{-28}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.342708120251196 \cdot 10^{+70}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot 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.1345533515695916e-28)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 1.342708120251196e+70)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* 2.0 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.1345533515695916e-28) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 1.342708120251196e+70) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (2.0 * 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.2 |
|---|---|
| Target | 20.7 |
| Herbie | 10.2 |
if b < -1.13455335156959156e-28Initial program 54.7
Simplified54.7
Taylor expanded in b around -inf 6.9
if -1.13455335156959156e-28 < b < 1.34270812025119594e70Initial program 15.0
if 1.34270812025119594e70 < b Initial program 42.0
Simplified42.0
Taylor expanded in b around inf 4.9
Simplified4.9
Final simplification10.2
herbie shell --seed 2022076
(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)))