\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 := b \cdot b - \left(4 \cdot a\right) \cdot c\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - b}\\
t_2 := \sqrt{t_0}\\
t_3 := \frac{\left(-b\right) + t_2}{2 \cdot a}\\
t_4 := \frac{2 \cdot c}{\left(-b\right) - t_2}\\
t_5 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{if}\;t_5 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;t_5 \leq -1.3645897516984646 \cdot 10^{-103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{c} \cdot \sqrt{\frac{b \cdot b}{c} - 4 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + {\left({t_0}^{0.25}\right)}^{2}}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;t_5 \leq 1.528805314766688 \cdot 10^{+226}:\\
\;\;\;\;t_5\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{b}{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) (* (* 4.0 a) c)))
(t_1 (/ (* 2.0 c) (- (- b) b)))
(t_2 (sqrt t_0))
(t_3 (/ (+ (- b) t_2) (* 2.0 a)))
(t_4 (/ (* 2.0 c) (- (- b) t_2)))
(t_5 (if (>= b 0.0) t_4 t_3)))
(if (<= t_5 (- INFINITY))
(if (>= b 0.0) t_4 (/ (+ (- b) (* -1.0 b)) (* 2.0 a)))
(if (<= t_5 -1.3645897516984646e-103)
(if (>= b 0.0)
(/
(* 2.0 c)
(- (- b) (* (sqrt c) (sqrt (- (/ (* b b) c) (* 4.0 a))))))
t_3)
(if (<= t_5 0.0)
(if (>= b 0.0) t_1 (/ (+ (- b) (pow (pow t_0 0.25) 2.0)) (* 2.0 a)))
(if (<= t_5 1.528805314766688e+226)
t_5
(if (>= b 0.0) t_1 (* -1.0 (/ b 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) - ((4.0 * a) * c);
double t_1 = (2.0 * c) / (-b - b);
double t_2 = sqrt(t_0);
double t_3 = (-b + t_2) / (2.0 * a);
double t_4 = (2.0 * c) / (-b - t_2);
double tmp;
if (b >= 0.0) {
tmp = t_4;
} else {
tmp = t_3;
}
double t_5 = tmp;
double tmp_2;
if (t_5 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_4;
} else {
tmp_3 = (-b + (-1.0 * b)) / (2.0 * a);
}
tmp_2 = tmp_3;
} else if (t_5 <= -1.3645897516984646e-103) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - (sqrt(c) * sqrt((((b * b) / c) - (4.0 * a)))));
} else {
tmp_4 = t_3;
}
tmp_2 = tmp_4;
} else if (t_5 <= 0.0) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = t_1;
} else {
tmp_5 = (-b + pow(pow(t_0, 0.25), 2.0)) / (2.0 * a);
}
tmp_2 = tmp_5;
} else if (t_5 <= 1.528805314766688e+226) {
tmp_2 = t_5;
} else if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -1.0 * (b / a);
}
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 17.1
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))) < -1.36458975169846462e-103Initial program 3.1
Applied egg-rr2.3
if -1.36458975169846462e-103 < (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 26.9
Taylor expanded in b around inf 11.0
Applied egg-rr11.1
if -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))) < 1.52880531476668788e226Initial program 2.8
if 1.52880531476668788e226 < (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 50.7
Taylor expanded in b around inf 48.2
Taylor expanded in b around -inf 13.8
Final simplification7.4
herbie shell --seed 2022127
(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))))