\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.0182283612543797 \cdot 10^{+81}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -3.089056825403424 \cdot 10^{-228}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 1.3389678122082543 \cdot 10^{+61}:\\
\;\;\;\;-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.0182283612543797e+81)
(- (/ c b) (/ b a))
(if (<= b -3.089056825403424e-228)
(/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) (* a 2.0))
(if (<= b 1.3389678122082543e+61)
(* -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.0182283612543797e+81) {
tmp = (c / b) - (b / a);
} else if (b <= -3.089056825403424e-228) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) - b) / (a * 2.0);
} else if (b <= 1.3389678122082543e+61) {
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 | 34.1 |
|---|---|
| Target | 21.3 |
| Herbie | 6.9 |
if b < -1.0182283612543797e81Initial program 43.0
Simplified43.0
Taylor expanded around -inf 4.9
if -1.0182283612543797e81 < b < -3.0890568254034239e-228Initial program 8.2
if -3.0890568254034239e-228 < b < 1.3389678122082543e61Initial program 28.2
Simplified28.2
rmApplied flip--_binary64_73528.3
Simplified16.9
Simplified16.9
rmApplied *-un-lft-identity_binary64_76016.9
Applied times-frac_binary64_76615.0
Applied times-frac_binary64_76610.5
Simplified10.5
Simplified10.5
if 1.3389678122082543e61 < b Initial program 57.5
Simplified57.5
Taylor expanded around inf 3.0
Simplified3.0
Final simplification6.9
herbie shell --seed 2020349
(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)))