\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 -3.7496976833374853 \cdot 10^{+80}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq -1.705747609312796 \cdot 10^{-292}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.2974215110058318 \cdot 10^{+148}:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\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 -3.7496976833374853e+80)
(- (/ b a))
(if (<= b -1.705747609312796e-292)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(if (<= b 2.2974215110058318e+148)
(/ (* c -2.0) (+ b (sqrt (- (* b b) (* 4.0 (* a c))))))
(- (/ 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 <= -3.7496976833374853e+80) {
tmp = -(b / a);
} else if (b <= -1.705747609312796e-292) {
tmp = (sqrt((b * b) - (4.0 * (a * c))) - b) / (a * 2.0);
} else if (b <= 2.2974215110058318e+148) {
tmp = (c * -2.0) / (b + sqrt((b * b) - (4.0 * (a * c))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.5 |
|---|---|
| Target | 20.9 |
| Herbie | 6.6 |
if b < -3.7496976833374853e80Initial program 42.9
Simplified42.9
Taylor expanded around -inf 4.9
if -3.7496976833374853e80 < b < -1.70574760931279604e-292Initial program 8.9
Simplified8.9
rmApplied sub-neg_binary648.9
if -1.70574760931279604e-292 < b < 2.2974215110058318e148Initial program 32.9
Simplified32.9
rmApplied div-inv_binary6432.9
Simplified32.9
rmApplied flip--_binary6432.9
Applied associate-*l/_binary6433.0
Simplified32.9
Taylor expanded around 0 8.2
if 2.2974215110058318e148 < b Initial program 63.5
Simplified63.5
Taylor expanded around inf 1.7
Final simplification6.6
herbie shell --seed 2021174
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
: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)))