\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 - c \cdot \left(a \cdot 4\right)}\\
t_1 := \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\\
\mathbf{if}\;b \leq -2.9527445303397572 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + t_1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.545049901184398 \cdot 10^{+121}:\\
\;\;\;\;\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}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_1 - 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 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1 (sqrt (fma a (* c -4.0) (* b b)))))
(if (<= b -2.9527445303397572e+153)
(if (>= b 0.0) (* -0.5 (/ (+ b t_1) a)) (/ (* c 2.0) (- (- b) b)))
(if (<= b 5.545049901184398e+121)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b)))
(if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (/ (* c 2.0) (- t_1 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 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = sqrt(fma(a, (c * -4.0), (b * b)));
double tmp_1;
if (b <= -2.9527445303397572e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * ((b + t_1) / a);
} else {
tmp_2 = (c * 2.0) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b <= 5.545049901184398e+121) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = (c * 2.0) / (t_1 - b);
}
return tmp_1;
}



Bits error versus a



Bits error versus b



Bits error versus c
if b < -2.9527445303397572e153Initial program 37.6
Simplified37.5
Taylor expanded in b around -inf 1.4
if -2.9527445303397572e153 < b < 5.54504990118439818e121Initial program 8.9
if 5.54504990118439818e121 < b Initial program 53.2
Simplified53.2
Taylor expanded in a around 0 2.9
Final simplification6.7
herbie shell --seed 2022125
(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)))))))