\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 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
t_2 := \frac{c \cdot 2}{\left(-b\right) - b}\\
\mathbf{if}\;t_1 \leq -2.2478066317801205 \cdot 10^{+208}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\\
t_4 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + t_3}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_3 - b}\\
\end{array}\\
\mathbf{if}\;t_1 \leq -3.1847072390323827 \cdot 10^{-224}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;t_1 \leq 1.4935923143638092 \cdot 10^{+274}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\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 (sqrt (- (* b b) (* (* 4.0 a) c))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b))))
(t_2 (/ (* c 2.0) (- (- b) b))))
(if (<= t_1 -2.2478066317801205e+208)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_2)
(let* ((t_3 (sqrt (fma a (* c -4.0) (* b b))))
(t_4
(if (>= b 0.0) (* -0.5 (/ (+ b t_3) a)) (/ (* c 2.0) (- t_3 b)))))
(if (<= t_1 -3.1847072390323827e-224)
t_4
(if (<= t_1 0.0)
(if (>= b 0.0) (* (+ b (sqrt (* c (* a -4.0)))) (/ -0.5 a)) t_2)
(if (<= t_1 1.4935923143638092e+274)
t_4
(if (>= b 0.0) (/ (- b) a) t_2))))))))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 = sqrt((b * b) - ((4.0 * a) * c));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (a * 2.0);
} else {
tmp = (c * 2.0) / (t_0 - b);
}
double t_1 = tmp;
double t_2 = (c * 2.0) / (-b - b);
double tmp_2;
if (t_1 <= -2.2478066317801205e+208) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c / b) - (b / a);
} else {
tmp_3 = t_2;
}
tmp_2 = tmp_3;
} else {
double t_3 = sqrt(fma(a, (c * -4.0), (b * b)));
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + t_3) / a);
} else {
tmp_4 = (c * 2.0) / (t_3 - b);
}
double t_4 = tmp_4;
double tmp_5;
if (t_1 <= -3.1847072390323827e-224) {
tmp_5 = t_4;
} else if (t_1 <= 0.0) {
double tmp_6;
if (b >= 0.0) {
tmp_6 = (b + sqrt(c * (a * -4.0))) * (-0.5 / a);
} else {
tmp_6 = t_2;
}
tmp_5 = tmp_6;
} else if (t_1 <= 1.4935923143638092e+274) {
tmp_5 = t_4;
} else if (b >= 0.0) {
tmp_5 = -b / a;
} else {
tmp_5 = t_2;
}
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 (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.24780663178012049e208Initial program 44.8
Taylor expanded in b around -inf 47.7
Taylor expanded in b around inf 17.1
if -2.24780663178012049e208 < (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)))))) < -3.18470723903238272e-224 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)))))) < 1.4935923143638092e274Initial program 3.0
Simplified3.0
if -3.18470723903238272e-224 < (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 33.3
Taylor expanded in b around -inf 9.8
Applied div-inv_binary649.8
Simplified9.8
Taylor expanded in b around 0 9.9
Simplified9.9
if 1.4935923143638092e274 < (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 58.6
Taylor expanded in b around -inf 52.2
Taylor expanded in b around inf 13.5
Final simplification7.1
herbie shell --seed 2022077
(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)))))))