\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 -4.1675890391810646 \cdot 10^{+147}:\\
\;\;\;\;\frac{-b}{a \cdot 2}\\
\mathbf{elif}\;b \leq -1.346684968652724 \cdot 10^{-176}:\\
\;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{2}}}\\
\mathbf{elif}\;b \leq 2.857075353436113 \cdot 10^{+153}:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \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 -4.1675890391810646e+147)
(/ (- b) (* a 2.0))
(if (<= b -1.346684968652724e-176)
(/ 1.0 (/ a (/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) 2.0)))
(if (<= b 2.857075353436113e+153)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* 4.0 (* a c)))))))
(* -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 <= -4.1675890391810646e+147) {
tmp = -b / (a * 2.0);
} else if (b <= -1.346684968652724e-176) {
tmp = 1.0 / (a / ((sqrt((b * b) - (4.0 * (a * c))) - b) / 2.0));
} else if (b <= 2.857075353436113e+153) {
tmp = -2.0 * (c / (b + sqrt((b * b) - (4.0 * (a * c)))));
} else {
tmp = -2.0 * (c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 20.6 |
| Herbie | 17.5 |
if b < -4.1675890391810646e147Initial program 61.7
Simplified61.7
Taylor expanded around 0 52.3
if -4.1675890391810646e147 < b < -1.346684968652724e-176Initial program 7.1
Simplified7.1
rmApplied clear-num_binary64_6637.3
Simplified7.3
if -1.346684968652724e-176 < b < 2.8570753534361131e153Initial program 30.9
Simplified30.9
rmApplied flip--_binary64_68631.0
Simplified15.1
Simplified15.1
rmApplied *-un-lft-identity_binary64_66015.1
Applied times-frac_binary64_65513.3
Applied times-frac_binary64_6558.6
Simplified8.6
Simplified8.6
if 2.8570753534361131e153 < b Initial program 63.9
Simplified63.9
rmApplied flip--_binary64_68663.9
Simplified37.9
Simplified37.9
rmApplied *-un-lft-identity_binary64_66037.9
Applied times-frac_binary64_65537.7
Applied times-frac_binary64_65537.7
Simplified37.7
Simplified37.7
Taylor expanded around 0 32.5
Final simplification17.5
herbie shell --seed 2020270
(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)))