\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 := -4 \cdot \left(a \cdot c\right)\\
t_1 := \frac{\left(-b\right) - b}{2 \cdot a}\\
t_2 := \left(4 \cdot a\right) \cdot c\\
t_3 := \sqrt{b \cdot b - t_2}\\
t_4 := \frac{\left(-b\right) - t_3}{2 \cdot a}\\
t_5 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_3}\\
\end{array}\\
t_6 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -t_2\right)}}\\
\end{array}\\
\mathbf{if}\;t_5 \leq -2.0441723957830525 \cdot 10^{+163}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(b, \frac{c}{t_0}, \frac{c}{\sqrt{t_0}}\right)\\
\end{array}\\
\mathbf{elif}\;t_5 \leq -2.7283497524080452 \cdot 10^{-189}:\\
\;\;\;\;t_6\\
\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{-b \cdot 2}\\
\end{array}\\
\mathbf{elif}\;t_5 \leq 1.4800849406987464 \cdot 10^{+262}:\\
\;\;\;\;t_6\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\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 (- (* 4.0 (* a c))))
(t_1 (/ (- (- b) b) (* 2.0 a)))
(t_2 (* (* 4.0 a) c))
(t_3 (sqrt (- (* b b) t_2)))
(t_4 (/ (- (- b) t_3) (* 2.0 a)))
(t_5 (if (>= b 0.0) t_4 (/ (* 2.0 c) (+ (- b) t_3))))
(t_6
(if (>= b 0.0) t_4 (/ (* 2.0 c) (+ (- b) (sqrt (fma b b (- t_2))))))))
(if (<= t_5 -2.0441723957830525e+163)
(if (>= b 0.0) t_1 (* 2.0 (fma b (/ c t_0) (/ c (sqrt t_0)))))
(if (<= t_5 -2.7283497524080452e-189)
t_6
(if (<= t_5 0.0)
(if (>= b 0.0) t_4 (/ (* 2.0 c) (- (* b 2.0))))
(if (<= t_5 1.4800849406987464e+262)
t_6
(if (>= b 0.0) t_1 (* -1.0 (/ c b)))))))))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 = -(4.0 * (a * c));
double t_1 = (-b - b) / (2.0 * a);
double t_2 = (4.0 * a) * c;
double t_3 = sqrt(((b * b) - t_2));
double t_4 = (-b - t_3) / (2.0 * a);
double tmp;
if (b >= 0.0) {
tmp = t_4;
} else {
tmp = (2.0 * c) / (-b + t_3);
}
double t_5 = tmp;
double tmp_1;
if (b >= 0.0) {
tmp_1 = t_4;
} else {
tmp_1 = (2.0 * c) / (-b + sqrt(fma(b, b, -t_2)));
}
double t_6 = tmp_1;
double tmp_3;
if (t_5 <= -2.0441723957830525e+163) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_1;
} else {
tmp_4 = 2.0 * fma(b, (c / t_0), (c / sqrt(t_0)));
}
tmp_3 = tmp_4;
} else if (t_5 <= -2.7283497524080452e-189) {
tmp_3 = t_6;
} else if (t_5 <= 0.0) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = t_4;
} else {
tmp_5 = (2.0 * c) / -(b * 2.0);
}
tmp_3 = tmp_5;
} else if (t_5 <= 1.4800849406987464e+262) {
tmp_3 = t_6;
} else if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = -1.0 * (c / b);
}
return tmp_3;
}



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.04417239578305246e163Initial program 37.2
Taylor expanded in b around inf 15.7
Taylor expanded in b around 0 17.6
Simplified17.5
if -2.04417239578305246e163 < (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.72834975240804524e-189 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.4800849406987464e262Initial program 3.0
Applied egg-rr3.0
if -2.72834975240804524e-189 < (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 32.8
Applied egg-rr32.8
Taylor expanded in b around -inf 10.8
Simplified10.8
if 1.4800849406987464e262 < (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 57.7
Taylor expanded in b around inf 19.8
Taylor expanded in b around -inf 14.5
Final simplification7.8
herbie shell --seed 2022129
(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)))))))