\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 -4.630605456274428 \cdot 10^{+153}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 6.55350763957002 \cdot 10^{-255}:\\
\;\;\;\;-0.5 \cdot \left(4 \cdot \frac{c}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\right)\\
\mathbf{elif}\;b \leq 1.9271617357234682 \cdot 10^{+116}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \left(\frac{b}{a} - \frac{c}{b}\right)\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 -4.630605456274428e+153)
(* -0.5 (* 2.0 (/ c b)))
(if (<= b 6.55350763957002e-255)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.9271617357234682e+116)
(* -0.5 (/ (+ b (sqrt (+ (* b b) (* a (* c -4.0))))) a))
(* -0.5 (* 2.0 (- (/ b a) (/ 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 <= -4.630605456274428e+153) {
tmp = -0.5 * (2.0 * (c / b));
} else if (b <= 6.55350763957002e-255) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.9271617357234682e+116) {
tmp = -0.5 * ((b + sqrt((b * b) + (a * (c * -4.0)))) / a);
} else {
tmp = -0.5 * (2.0 * ((b / a) - (c / b)));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.6 |
|---|---|
| Target | 21.4 |
| Herbie | 6.4 |
if b < -4.63060545627442765e153Initial program 63.9
Simplified63.9
Taylor expanded around -inf 1.2
if -4.63060545627442765e153 < b < 6.55350763957002e-255Initial program 34.2
Simplified34.2
rmApplied flip-+_binary64_139934.2
Simplified16.8
rmApplied *-un-lft-identity_binary64_142516.8
Applied *-un-lft-identity_binary64_142516.8
Applied times-frac_binary64_143116.8
Applied times-frac_binary64_143116.8
Simplified16.8
Simplified9.0
if 6.55350763957002e-255 < b < 1.9271617357234682e116Initial program 7.8
Simplified7.8
rmApplied sub-neg_binary64_14187.8
Simplified7.8
if 1.9271617357234682e116 < b Initial program 50.8
Simplified50.8
Taylor expanded around inf 3.2
Simplified3.2
Final simplification6.4
herbie shell --seed 2020303
(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)))