\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.3014879836557515 \cdot 10^{+97}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -1.8145284637786566 \cdot 10^{-293}:\\
\;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{2}}}\\
\mathbf{elif}\;b \leq 6.972667102848289 \cdot 10^{+99}:\\
\;\;\;\;\frac{c \cdot -2}{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.3014879836557515e+97)
(- (/ c b) (/ b a))
(if (<= b -1.8145284637786566e-293)
(/ 1.0 (/ a (/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) 2.0)))
(if (<= b 6.972667102848289e+99)
(/ (* c -2.0) (+ 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.3014879836557515e+97) {
tmp = (c / b) - (b / a);
} else if (b <= -1.8145284637786566e-293) {
tmp = 1.0 / (a / ((sqrt((b * b) - (4.0 * (c * a))) - b) / 2.0));
} else if (b <= 6.972667102848289e+99) {
tmp = (c * -2.0) / (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 | 34.5 |
|---|---|
| Target | 21.1 |
| Herbie | 6.8 |
if b < -1.3014879836557515e97Initial program 46.0
Simplified46.0
Taylor expanded around -inf 3.9
if -1.3014879836557515e97 < b < -1.81452846377865664e-293Initial program 9.6
Simplified9.6
rmApplied clear-num_binary64_7669.7
Simplified9.7
if -1.81452846377865664e-293 < b < 6.97266710284828931e99Initial program 31.7
Simplified31.7
rmApplied flip--_binary64_74231.7
Simplified16.2
Simplified16.2
rmApplied div-inv_binary64_76416.2
Applied times-frac_binary64_77315.2
Simplified9.0
Simplified9.0
rmApplied associate-*r/_binary64_7098.8
Simplified8.8
if 6.97266710284828931e99 < b Initial program 59.4
Simplified59.4
Taylor expanded around inf 2.7
Simplified2.7
Final simplification6.8
herbie shell --seed 2020292
(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)))