\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.5894887112160012 \cdot 10^{+56}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.131198222427231 \cdot 10^{-227}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 5.525835260688754 \cdot 10^{+121}:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\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 -1.5894887112160012e+56)
(- (/ c b) (/ b a))
(if (<= b 7.131198222427231e-227)
(/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) (* a 2.0))
(if (<= b 5.525835260688754e+121)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* 4.0 (* c 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.5894887112160012e+56) {
tmp = (c / b) - (b / a);
} else if (b <= 7.131198222427231e-227) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) - b) / (a * 2.0);
} else if (b <= 5.525835260688754e+121) {
tmp = -2.0 * (c / (b + sqrt((b * b) - (4.0 * (c * a)))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.6 |
|---|---|
| Target | 20.5 |
| Herbie | 6.7 |
if b < -1.5894887112160012e56Initial program 38.1
Simplified38.1
Taylor expanded around -inf 5.6
if -1.5894887112160012e56 < b < 7.131198222427231e-227Initial program 10.3
Simplified10.3
if 7.131198222427231e-227 < b < 5.52583526068875372e121Initial program 36.8
Simplified36.8
rmApplied flip--_binary64_74236.8
Simplified17.2
Simplified17.2
rmApplied *-un-lft-identity_binary64_76717.2
Applied times-frac_binary64_77314.4
Applied times-frac_binary64_7737.1
Simplified7.1
Simplified7.1
if 5.52583526068875372e121 < b Initial program 61.3
Simplified61.3
Taylor expanded around inf 1.7
Simplified1.7
Final simplification6.7
herbie shell --seed 2020281
(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)))