\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 := \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\\
t_3 := \frac{c \cdot 2}{t_2 - b}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := -0.5 \cdot \frac{b + t_2}{a}\\
\mathbf{if}\;t_1 \leq -1.447111872177247 \cdot 10^{-234}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{elif}\;t_1 \leq 2.66443530772995 \cdot 10^{-198}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \left(\frac{a \cdot c}{b} - b\right)}\\
\end{array}\\
\mathbf{elif}\;t_1 \leq 4.647143835031893 \cdot 10^{+279}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_5 := \sqrt{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}\\
\frac{c \cdot 2}{t_5 \cdot t_5 - b}
\end{array}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{b}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{b \cdot -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 (sqrt (fma a (* c -4.0) (* b b))))
(t_3 (/ (* c 2.0) (- t_2 b))))
(if (<= t_1 (- INFINITY))
(if (>= b 0.0) (* -0.5 (/ (+ b b) a)) t_3)
(let* ((t_4 (* -0.5 (/ (+ b t_2) a))))
(if (<= t_1 -1.447111872177247e-234)
(if (>= b 0.0) t_4 t_3)
(if (<= t_1 2.66443530772995e-198)
(if (>= b 0.0) t_4 (/ (* c 2.0) (* 2.0 (- (/ (* a c) b) b))))
(if (<= t_1 4.647143835031893e+279)
(if (>= b 0.0)
t_4
(let* ((t_5 (sqrt (hypot b (sqrt (* a (* c -4.0)))))))
(/ (* c 2.0) (- (* t_5 t_5) b))))
(if (>= b 0.0)
(* -0.5 (* 2.0 (/ b a)))
(/ (* c 2.0) (* b -2.0))))))))))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 = sqrt(fma(a, (c * -4.0), (b * b)));
double t_3 = (c * 2.0) / (t_2 - b);
double tmp_2;
if (t_1 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((b + b) / a);
} else {
tmp_3 = t_3;
}
tmp_2 = tmp_3;
} else {
double t_4 = -0.5 * ((b + t_2) / a);
double tmp_5;
if (t_1 <= -1.447111872177247e-234) {
double tmp_6;
if (b >= 0.0) {
tmp_6 = t_4;
} else {
tmp_6 = t_3;
}
tmp_5 = tmp_6;
} else if (t_1 <= 2.66443530772995e-198) {
double tmp_7;
if (b >= 0.0) {
tmp_7 = t_4;
} else {
tmp_7 = (c * 2.0) / (2.0 * (((a * c) / b) - b));
}
tmp_5 = tmp_7;
} else if (t_1 <= 4.647143835031893e+279) {
double tmp_8;
if (b >= 0.0) {
tmp_8 = t_4;
} else {
double t_5 = sqrt(hypot(b, sqrt(a * (c * -4.0))));
tmp_8 = (c * 2.0) / ((t_5 * t_5) - b);
}
tmp_5 = tmp_8;
} else if (b >= 0.0) {
tmp_5 = -0.5 * (2.0 * (b / a));
} else {
tmp_5 = (c * 2.0) / (b * -2.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 (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.0Initial program 64.0
Simplified64.0
Taylor expanded in a around 0 18.6
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.44711187217724713e-234Initial program 2.6
Simplified2.7
if -1.44711187217724713e-234 < (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.66443530772995e-198Initial program 30.0
Simplified29.9
Applied add-sqr-sqrt_binary6430.0
Applied fma-neg_binary6429.9
Taylor expanded in b around -inf 11.3
Simplified11.3
if 2.66443530772995e-198 < (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)))))) < 4.6471438350318928e279Initial program 2.9
Simplified2.8
Applied add-sqr-sqrt_binary642.8
Applied sqrt-prod_binary643.0
Simplified8.7
Simplified8.2
if 4.6471438350318928e279 < (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.9
Simplified60.7
Taylor expanded in b around -inf 56.1
Taylor expanded in b around inf 13.9
Final simplification8.6
herbie shell --seed 2021215
(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)))))))