\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.5954141730712636 \cdot 10^{+99}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.5461279104521085 \cdot 10^{-201}:\\
\;\;\;\;\frac{4}{2} \cdot \frac{c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}\\
\mathbf{elif}\;b \leq 2.673025417100217 \cdot 10^{+33}:\\
\;\;\;\;\left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \cdot \frac{-1}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \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 -1.5954141730712636e+99)
(- (* 1.0 (/ c b)))
(if (<= b 1.5461279104521085e-201)
(* (/ 4.0 2.0) (/ c (- (sqrt (- (* b b) (* 4.0 (* c a)))) b)))
(if (<= b 2.673025417100217e+33)
(* (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) (/ -1.0 (* 2.0 a)))
(* 1.0 (- (/ c b) (/ 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.5954141730712636e+99)) {
tmp = ((double) -(((double) (1.0 * (c / b)))));
} else {
double tmp_1;
if ((b <= 1.5461279104521085e-201)) {
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 <= 2.673025417100217e+33)) {
tmp_2 = ((double) (((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (4.0 * ((double) (c * a)))))))))) * (-1.0 / ((double) (2.0 * a)))));
} else {
tmp_2 = ((double) (1.0 * ((double) ((c / b) - (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.3 |
|---|---|
| Target | 20.8 |
| Herbie | 7.3 |
if b < -1.5954141730712636e99Initial program 59.0
Taylor expanded around -inf 2.8
if -1.5954141730712636e99 < b < 1.5461279104521085e-201Initial program 30.1
rmApplied flip--_binary6430.3
Simplified16.8
Simplified16.8
rmApplied *-un-lft-identity_binary6416.8
Applied times-frac_binary6416.8
Applied times-frac_binary6416.8
Simplified16.8
Simplified9.9
if 1.5461279104521085e-201 < b < 2.67302541710021697e33Initial program 8.5
rmApplied div-inv_binary648.7
Simplified8.7
if 2.67302541710021697e33 < b Initial program 34.9
Taylor expanded around inf 6.7
Simplified6.7
Final simplification7.3
herbie shell --seed 2020204
(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)))