\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 -9.653953438506672 \cdot 10^{+122}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 9.329496704353122 \cdot 10^{-273}:\\
\;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.6022400513499554 \cdot 10^{+42}:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\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 -9.653953438506672e+122)
(- (/ c b) (/ b a))
(if (<= b 9.329496704353122e-273)
(/ (- (sqrt (+ (* b b) (* a (* c -4.0)))) b) (* a 2.0))
(if (<= b 2.6022400513499554e+42)
(* -2.0 (/ c (+ b (sqrt (+ (* b b) (* a (* c -4.0)))))))
(- (/ 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 <= -9.653953438506672e+122) {
tmp = (c / b) - (b / a);
} else if (b <= 9.329496704353122e-273) {
tmp = (sqrt((b * b) + (a * (c * -4.0))) - b) / (a * 2.0);
} else if (b <= 2.6022400513499554e+42) {
tmp = -2.0 * (c / (b + sqrt((b * b) + (a * (c * -4.0)))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.6 |
|---|---|
| Target | 20.7 |
| Herbie | 6.8 |
if b < -9.65395343850667215e122Initial program 53.2
Simplified53.2
Taylor expanded around -inf 3.0
if -9.65395343850667215e122 < b < 9.3294967043531217e-273Initial program 8.9
Simplified8.9
rmApplied sub-neg_binary648.9
Simplified8.9
if 9.3294967043531217e-273 < b < 2.60224005134995544e42Initial program 29.2
Simplified29.2
rmApplied sub-neg_binary6429.2
Simplified29.2
rmApplied flip--_binary6429.2
Simplified16.9
Simplified16.9
rmApplied *-un-lft-identity_binary6416.9
Applied times-frac_binary6414.1
Applied times-frac_binary649.2
Simplified9.2
Simplified9.2
if 2.60224005134995544e42 < b Initial program 56.8
Simplified56.8
Taylor expanded around inf 4.3
Simplified4.3
Final simplification6.8
herbie shell --seed 2020260
(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)))