\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \leq -2.0801679587946785 \cdot 10^{+111}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \leq -8.299193755122384 \cdot 10^{-299}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.425599302719474 \cdot 10^{+102}:\\
\;\;\;\;\left(-4\right) \cdot \frac{\frac{c}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -1\\
\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.0801679587946785e+111)
(* 1.0 (- (/ c b) (/ b a)))
(if (<= b -8.299193755122384e-299)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(if (<= b 2.425599302719474e+102)
(* (- 4.0) (/ (/ c (+ b (sqrt (- (* b b) (* c (* a 4.0)))))) 2.0))
(* (/ c b) -1.0)))))double code(double a, double b, double c) {
return (((double) (((double) -(b)) + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))) / ((double) (2.0 * a)));
}
double code(double a, double b, double c) {
double tmp;
if ((b <= -2.0801679587946785e+111)) {
tmp = ((double) (1.0 * ((double) ((c / b) - (b / a)))));
} else {
double tmp_1;
if ((b <= -8.299193755122384e-299)) {
tmp_1 = (((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 4.0)))))))) - b)) / ((double) (a * 2.0)));
} else {
double tmp_2;
if ((b <= 2.425599302719474e+102)) {
tmp_2 = ((double) (((double) -(4.0)) * ((c / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 4.0))))))))))) / 2.0)));
} else {
tmp_2 = ((double) ((c / b) * -1.0));
}
tmp_1 = tmp_2;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.1 |
|---|---|
| Target | 21.3 |
| Herbie | 6.4 |
if b < -2.08016795879467846e111Initial program Error: 49.5 bits
SimplifiedError: 49.5 bits
Taylor expanded around -inf Error: 3.4 bits
SimplifiedError: 3.4 bits
if -2.08016795879467846e111 < b < -8.29919375512238394e-299Initial program Error: 8.9 bits
SimplifiedError: 8.9 bits
if -8.29919375512238394e-299 < b < 2.42559930271947385e102Initial program Error: 31.7 bits
SimplifiedError: 31.7 bits
rmApplied flip--Error: 31.7 bits
SimplifiedError: 15.8 bits
SimplifiedError: 15.8 bits
rmApplied *-un-lft-identityError: 15.8 bits
Applied distribute-lft-neg-inError: 15.8 bits
Applied times-fracError: 13.2 bits
Applied times-fracError: 8.6 bits
SimplifiedError: 8.6 bits
if 2.42559930271947385e102 < b Initial program Error: 59.9 bits
SimplifiedError: 59.9 bits
Taylor expanded around inf Error: 2.3 bits
Final simplificationError: 6.4 bits
herbie shell --seed 2020205
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
: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)))