\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -1.7157042027839432 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{t_0 - b}{a \cdot 2}\\
\mathbf{if}\;b \leq 9.155679788397841 \cdot 10^{+120}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\end{array}
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -1.7157042027839432e+64)
(if (>= b 0.0) (* -2.0 (/ c (+ b t_0))) (/ (- (- b) b) (* a 2.0)))
(let* ((t_1 (/ (- t_0 b) (* a 2.0))))
(if (<= b 9.155679788397841e+120)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) t_1)
(if (>= b 0.0) (* -2.0 (/ c (+ b b))) t_1))))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - sqrt((b * b) - ((4.0 * a) * c)));
} else {
tmp = (-b + sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
}
return tmp;
}
double code(double a, double b, double c) {
double t_0 = sqrt((b * b) - (c * (4.0 * a)));
double tmp_1;
if (b <= -1.7157042027839432e+64) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + t_0));
} else {
tmp_2 = (-b - b) / (a * 2.0);
}
tmp_1 = tmp_2;
} else {
double t_1 = (t_0 - b) / (a * 2.0);
double tmp_4;
if (b <= 9.155679788397841e+120) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = (c * 2.0) / (-b - t_0);
} else {
tmp_5 = t_1;
}
tmp_4 = tmp_5;
} else if (b >= 0.0) {
tmp_4 = -2.0 * (c / (b + b));
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
}
return tmp_1;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -1.7157042027839432e64Initial program 41.3
Simplified41.3
Taylor expanded around -inf 5.4
Simplified5.4
if -1.7157042027839432e64 < b < 9.15567978839784072e120Initial program 9.2
if 9.15567978839784072e120 < b Initial program 33.1
Simplified33.1
Taylor expanded around inf 1.8
Final simplification6.9
herbie shell --seed 2021196
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))