\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.9209858444379851 \cdot 10^{+146}:\\
\;\;\;\;\frac{c}{b} \cdot -1\\
\mathbf{elif}\;b \leq 7.420373164236022 \cdot 10^{-279}:\\
\;\;\;\;\frac{4}{2} \cdot \frac{c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}\\
\mathbf{elif}\;b \leq 1.304608330782827 \cdot 10^{+64}:\\
\;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\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.9209858444379851e+146)
(* (/ c b) -1.0)
(if (<= b 7.420373164236022e-279)
(* (/ 4.0 2.0) (/ c (- (sqrt (- (* b b) (* 4.0 (* c a)))) b)))
(if (<= b 1.304608330782827e+64)
(- (/ (- b) (* 2.0 a)) (/ (sqrt (- (* b b) (* 4.0 (* c a)))) (* 2.0 a)))
(* -1.0 (/ b a))))))double code(double a, double b, double c) {
return (((double) (((double) -(b)) - ((double) sqrt(((double) (((double) (b * b)) - ((double) (4.0 * ((double) (a * c)))))))))) / ((double) (2.0 * a)));
}
double code(double a, double b, double c) {
double tmp;
if ((b <= -1.9209858444379851e+146)) {
tmp = ((double) ((c / b) * -1.0));
} else {
double tmp_1;
if ((b <= 7.420373164236022e-279)) {
tmp_1 = ((double) ((4.0 / 2.0) * (c / ((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (4.0 * ((double) (c * a)))))))) - b)))));
} else {
double tmp_2;
if ((b <= 1.304608330782827e+64)) {
tmp_2 = ((double) ((((double) -(b)) / ((double) (2.0 * a))) - (((double) sqrt(((double) (((double) (b * b)) - ((double) (4.0 * ((double) (c * a)))))))) / ((double) (2.0 * a)))));
} else {
tmp_2 = ((double) (-1.0 * (b / a)));
}
tmp_1 = tmp_2;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.5 |
|---|---|
| Target | 21.2 |
| Herbie | 6.7 |
if b < -1.9209858444379851e146Initial program 63.3
Taylor expanded around -inf 2.2
Simplified2.2
if -1.9209858444379851e146 < b < 7.4203731642360218e-279Initial program 33.1
rmApplied flip--_binary6433.1
Simplified15.2
Simplified15.2
rmApplied *-un-lft-identity_binary6415.2
Applied times-frac_binary6415.2
Applied times-frac_binary6415.2
Simplified15.2
Simplified8.0
if 7.4203731642360218e-279 < b < 1.304608330782827e64Initial program 9.2
rmApplied div-sub_binary649.2
Simplified9.2
Simplified9.2
if 1.304608330782827e64 < b Initial program 41.4
rmApplied flip--_binary6461.7
Simplified60.9
Simplified60.9
Taylor expanded around 0 5.6
Final simplification6.7
herbie shell --seed 2020205
(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)))