\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.068668780742819 \cdot 10^{+85}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := 4 \cdot \left(c \cdot a\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -2.2515171662899013 \cdot 10^{-173}:\\
\;\;\;\;\frac{t_0 \cdot \frac{0.5}{a}}{t_1 - b}\\
\mathbf{elif}\;b \leq 1.6598215864349702 \cdot 10^{+99}:\\
\;\;\;\;\frac{-b}{a \cdot 2} - \frac{t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\end{array}\\
\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.068668780742819e+85)
(- (/ c b))
(let* ((t_0 (* 4.0 (* c a))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= b -2.2515171662899013e-173)
(/ (* t_0 (/ 0.5 a)) (- t_1 b))
(if (<= b 1.6598215864349702e+99)
(- (/ (- b) (* a 2.0)) (/ t_1 (* a 2.0)))
(/ (- (- b) b) (* a 2.0)))))))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.068668780742819e+85) {
tmp = -(c / b);
} else {
double t_0 = 4.0 * (c * a);
double t_1 = sqrt((b * b) - t_0);
double tmp_1;
if (b <= -2.2515171662899013e-173) {
tmp_1 = (t_0 * (0.5 / a)) / (t_1 - b);
} else if (b <= 1.6598215864349702e+99) {
tmp_1 = (-b / (a * 2.0)) - (t_1 / (a * 2.0));
} else {
tmp_1 = (-b - b) / (a * 2.0);
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 31.2 |
|---|---|
| Target | 19.1 |
| Herbie | 8.0 |
if b < -4.06866878074281868e85Initial program 58.3
Taylor expanded in b around -inf 2.5
Simplified2.5
if -4.06866878074281868e85 < b < -2.2515171662899013e-173Initial program 38.3
Applied clear-num_binary6438.4
Applied flip--_binary6438.6
Applied associate-/r/_binary6438.6
Applied associate-/r*_binary6438.7
Simplified16.2
if -2.2515171662899013e-173 < b < 1.6598215864349702e99Initial program 10.6
Applied div-sub_binary6410.6
if 1.6598215864349702e99 < b Initial program 29.7
Taylor expanded in b around inf 2.6
Final simplification8.0
herbie shell --seed 2022088
(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)))