\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 := \left(-b\right) - b\\
t_1 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -4.439565493803235 \cdot 10^{-48}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.029795161598339 \cdot 10^{+117}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \left(\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right) - b\right)}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - b}{2 \cdot a}\\
\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 (- (- b) b)) (t_1 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -4.439565493803235e-48)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) (/ t_0 (* 2.0 a)))
(if (<= b 5.029795161598339e+117)
(if (>= b 0.0)
(* c (/ -2.0 (+ b (sqrt (fma a (* c -4.0) (* b b))))))
(/ (* 0.5 (- (hypot b (sqrt (* a (* c -4.0)))) b)) a))
(if (>= b 0.0) (/ (* 2.0 c) t_0) (/ (- t_1 b) (* 2.0 a)))))))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 = -b - b;
double t_1 = sqrt((b * b) - (c * (4.0 * a)));
double tmp_1;
if (b <= -4.439565493803235e-48) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_1);
} else {
tmp_2 = t_0 / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 5.029795161598339e+117) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (b + sqrt(fma(a, (c * -4.0), (b * b)))));
} else {
tmp_3 = (0.5 * (hypot(b, sqrt(a * (c * -4.0))) - b)) / a;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / t_0;
} else {
tmp_1 = (t_1 - b) / (2.0 * a);
}
return tmp_1;
}



Bits error versus a



Bits error versus b



Bits error versus c
if b < -4.4395654938032352e-48Initial program 28.7
Taylor expanded in b around -inf 9.9
if -4.4395654938032352e-48 < b < 5.0297951615983392e117Initial program 9.7
Simplified9.8
Applied associate-*r/_binary649.7
Simplified10.2
if 5.0297951615983392e117 < b Initial program 31.0
Taylor expanded in b around inf 1.9
Final simplification8.3
herbie shell --seed 2022020
(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))))