\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 -2.7823652310513766 \cdot 10^{+65}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq -7524134179.167663:\\
\;\;\;\;-0.5 \cdot \frac{\frac{4 \cdot \left(c \cdot a\right)}{a}}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\
\mathbf{elif}\;b \leq -3.559620564434074 \cdot 10^{-74}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 3.685989243441257 \cdot 10^{+139}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{b}{a}\right)\\
\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 -2.7823652310513766e+65)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b -7524134179.167663)
(*
-0.5
(/ (/ (* 4.0 (* c a)) a) (- b (sqrt (- (* b b) (* 4.0 (* c a)))))))
(if (<= b -3.559620564434074e-74)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 3.685989243441257e+139)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) a))
(* -0.5 (* 2.0 (/ b a))))))))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 <= -2.7823652310513766e+65) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= -7524134179.167663) {
tmp = -0.5 * (((4.0 * (c * a)) / a) / (b - sqrt((b * b) - (4.0 * (c * a)))));
} else if (b <= -3.559620564434074e-74) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 3.685989243441257e+139) {
tmp = -0.5 * ((b + sqrt((b * b) - (4.0 * (c * a)))) / a);
} else {
tmp = -0.5 * (2.0 * (b / a));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.8 |
|---|---|
| Target | 20.9 |
| Herbie | 9.8 |
if b < -2.7823652310513766e65 or -7524134179.16766262 < b < -3.559620564434074e-74Initial program 53.7
Simplified53.7
Taylor expanded around -inf 8.3
if -2.7823652310513766e65 < b < -7524134179.16766262Initial program 46.3
Simplified46.3
rmApplied div-inv_binary64_143946.3
rmApplied flip-+_binary64_141646.3
Applied associate-*l/_binary64_138546.3
Simplified11.0
if -3.559620564434074e-74 < b < 3.6859892434412571e139Initial program 12.5
Simplified12.5
if 3.6859892434412571e139 < b Initial program 57.1
Simplified57.1
rmApplied clear-num_binary64_144157.1
Taylor expanded around 0 2.5
Final simplification9.8
herbie shell --seed 2020308
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))