\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.751555112720535 \cdot 10^{+107}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -3.835865055607966 \cdot 10^{-308}:\\
\;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 574334605182495:\\
\;\;\;\;\frac{\frac{c \cdot -4}{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -4}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}}{2}\\
\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.751555112720535e+107)
(- (/ c b) (/ b a))
(if (<= b -3.835865055607966e-308)
(/ (- (sqrt (+ (* b b) (* a (* c -4.0)))) b) (* a 2.0))
(if (<= b 574334605182495.0)
(/ (/ (* c -4.0) (+ b (sqrt (+ (* b b) (* a (* c -4.0)))))) 2.0)
(/ (/ (* c -4.0) (* 2.0 (- b (/ (* c a) b)))) 2.0)))))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.751555112720535e+107) {
tmp = (c / b) - (b / a);
} else if (b <= -3.835865055607966e-308) {
tmp = (sqrt((b * b) + (a * (c * -4.0))) - b) / (a * 2.0);
} else if (b <= 574334605182495.0) {
tmp = ((c * -4.0) / (b + sqrt((b * b) + (a * (c * -4.0))))) / 2.0;
} else {
tmp = ((c * -4.0) / (2.0 * (b - ((c * a) / b)))) / 2.0;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.8 |
|---|---|
| Target | 20.8 |
| Herbie | 8.2 |
if b < -4.751555112720535e107Initial program 48.3
Simplified48.3
Taylor expanded around -inf 3.1
if -4.751555112720535e107 < b < -3.83586505560796617e-308Initial program 9.4
Simplified9.4
rmApplied sub-neg_binary64_7539.4
Simplified9.4
if -3.83586505560796617e-308 < b < 574334605182495Initial program 26.5
Simplified26.5
rmApplied sub-neg_binary64_75326.5
Simplified26.5
rmApplied flip--_binary64_73526.6
Simplified17.0
Simplified17.0
rmApplied associate-/r*_binary64_70417.0
Simplified9.9
if 574334605182495 < b Initial program 56.1
Simplified56.1
rmApplied sub-neg_binary64_75356.1
Simplified56.1
rmApplied flip--_binary64_73556.1
Simplified27.1
Simplified27.1
rmApplied associate-/r*_binary64_70427.1
Simplified22.9
Taylor expanded around inf 8.1
Simplified8.1
Final simplification8.2
herbie shell --seed 2020339
(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)))