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



Bits error versus a



Bits error versus b



Bits error versus c
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 35.2
Simplified35.2
Taylor expanded in b around -inf 9.9
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))) < -2.92033663027148731e-204 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))) < 1.8968933166185423e231Initial program 3.0
if -2.92033663027148731e-204 < (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 33.8
Taylor expanded in b around inf 9.6
Applied log1p-expm1-u_binary649.6
Simplified9.7
if 1.8968933166185423e231 < (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 34.4
Taylor expanded in b around inf 32.3
Taylor expanded in b around -inf 10.4
Final simplification6.2
herbie shell --seed 2022068
(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))))