\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\begin{array}{l}
t_0 := \frac{c \cdot 2}{\left(-b\right) - b}\\
t_1 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
t_2 := \frac{\left(-b\right) - t_1}{a \cdot 2}\\
t_3 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_1 - b}\\
\end{array}\\
t_4 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_3 \leq -1.4776712111955874 \cdot 10^{-242}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;t_3 \leq 2.6669410046624163 \cdot 10^{+276}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_4\\
\end{array}
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* c 2.0) (- (- b) b)))
(t_1 (sqrt (- (* b b) (* (* 4.0 a) c))))
(t_2 (/ (- (- b) t_1) (* a 2.0)))
(t_3 (if (>= b 0.0) t_2 (/ (* c 2.0) (- t_1 b))))
(t_4 (if (>= b 0.0) (/ (- b) a) t_0)))
(if (<= t_3 (- INFINITY))
t_4
(if (<= t_3 -1.4776712111955874e-242)
t_3
(if (<= t_3 0.0)
(if (>= b 0.0) t_2 t_0)
(if (<= t_3 2.6669410046624163e+276) t_3 t_4))))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + sqrt((b * b) - ((4.0 * a) * c)));
}
return tmp;
}
double code(double a, double b, double c) {
double t_0 = (c * 2.0) / (-b - b);
double t_1 = sqrt((b * b) - ((4.0 * a) * c));
double t_2 = (-b - t_1) / (a * 2.0);
double tmp;
if (b >= 0.0) {
tmp = t_2;
} else {
tmp = (c * 2.0) / (t_1 - b);
}
double t_3 = tmp;
double tmp_1;
if (b >= 0.0) {
tmp_1 = -b / a;
} else {
tmp_1 = t_0;
}
double t_4 = tmp_1;
double tmp_2;
if (t_3 <= -((double) INFINITY)) {
tmp_2 = t_4;
} else if (t_3 <= -1.4776712111955874e-242) {
tmp_2 = t_3;
} else if (t_3 <= 0.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2;
} else {
tmp_3 = t_0;
}
tmp_2 = tmp_3;
} else if (t_3 <= 2.6669410046624163e+276) {
tmp_2 = t_3;
} else {
tmp_2 = t_4;
}
return tmp_2;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -inf.0 or 2.6669410046624163e276 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) Initial program 60.7
Taylor expanded in b around -inf 58.0
Taylor expanded in b around inf 13.5
if -inf.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -1.4776712111955874e-242 or -0.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < 2.6669410046624163e276Initial program 2.6
if -1.4776712111955874e-242 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -0.0Initial program 34.5
Taylor expanded in b around -inf 10.0
Applied *-un-lft-identity_binary6410.0
Applied cancel-sign-sub-inv_binary6410.0
Final simplification6.1
herbie shell --seed 2022081
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))