\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.5949872779844862 \cdot 10^{+153}:\\
\;\;\;\;\left(\frac{c}{b} - 0.5 \cdot \frac{b}{a}\right) - \frac{b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 1.392247260771699 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2} - \frac{b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\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.5949872779844862e+153)
(- (- (/ c b) (* 0.5 (/ b a))) (/ b (* a 2.0)))
(if (<= b 1.392247260771699e-22)
(- (/ (sqrt (- (* b b) (* 4.0 (* c a)))) (* a 2.0)) (/ b (* a 2.0)))
(- (/ 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 <= -2.5949872779844862e+153) {
tmp = ((c / b) - (0.5 * (b / a))) - (b / (a * 2.0));
} else if (b <= 1.392247260771699e-22) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) / (a * 2.0)) - (b / (a * 2.0));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.2 |
|---|---|
| Target | 20.0 |
| Herbie | 10.0 |
if b < -2.5949872779844862e153Initial program 63.8
Simplified63.8
rmApplied div-sub_binary64_41963.8
Taylor expanded around -inf 2.0
if -2.5949872779844862e153 < b < 1.39224726077169907e-22Initial program 13.4
Simplified13.4
rmApplied div-sub_binary64_41913.4
if 1.39224726077169907e-22 < b Initial program 54.8
Simplified54.8
Taylor expanded around inf 7.0
Simplified7.0
Final simplification10.0
herbie shell --seed 2020299
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-expected #f
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))