\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 := \frac{t_0}{2 \cdot a}\\
t_2 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_3 := \frac{t_2 - b}{2 \cdot a}\\
t_4 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_2}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -4\right)}, b\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;t_4 \leq -4.5029130615698045 \cdot 10^{-261}:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_5 := \frac{2 \cdot c}{t_0}\\
\mathbf{if}\;t_4 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_5\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{elif}\;t_4 \leq 2.0576002708653966 \cdot 10^{+238}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_5\\
\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 (- (- b) b))
(t_1 (/ t_0 (* 2.0 a)))
(t_2 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_3 (/ (- t_2 b) (* 2.0 a)))
(t_4 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_2)) t_3)))
(if (<= t_4 (- INFINITY))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (hypot (sqrt (* c (* a -4.0))) b)))
t_1)
(if (<= t_4 -4.5029130615698045e-261)
t_4
(let* ((t_5 (/ (* 2.0 c) t_0)))
(if (<= t_4 0.0)
(if (>= b 0.0) t_5 t_3)
(if (<= t_4 2.0576002708653966e+238)
t_4
(if (>= b 0.0) t_5 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 = -b - b;
double t_1 = t_0 / (2.0 * a);
double t_2 = sqrt((b * b) - (c * (4.0 * a)));
double t_3 = (t_2 - b) / (2.0 * a);
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_2);
} else {
tmp = t_3;
}
double t_4 = tmp;
double tmp_2;
if (t_4 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - hypot(sqrt(c * (a * -4.0)), b));
} else {
tmp_3 = t_1;
}
tmp_2 = tmp_3;
} else if (t_4 <= -4.5029130615698045e-261) {
tmp_2 = t_4;
} else {
double t_5 = (2.0 * c) / t_0;
double tmp_5;
if (t_4 <= 0.0) {
double tmp_6;
if (b >= 0.0) {
tmp_6 = t_5;
} else {
tmp_6 = t_3;
}
tmp_5 = tmp_6;
} else if (t_4 <= 2.0576002708653966e+238) {
tmp_5 = t_4;
} else if (b >= 0.0) {
tmp_5 = t_5;
} else {
tmp_5 = t_1;
}
tmp_2 = tmp_5;
}
return tmp_2;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -inf.0Initial program 64.0
Taylor expanded in b around -inf 15.7
Applied neg-sub0_binary6415.7
Applied associate--l-_binary6415.7
Simplified15.7
if -inf.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -4.5029130615698045e-261 or 0.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 2.0576002708653966e238Initial program 2.7
if -4.5029130615698045e-261 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 0.0Initial program 35.7
Taylor expanded in b around inf 10.2
if 2.0576002708653966e238 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) Initial program 53.6
Taylor expanded in b around -inf 20.0
Taylor expanded in b around inf 16.4
Final simplification6.7
herbie shell --seed 2022081
(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))))