\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(a \cdot 4\right) \cdot c}\\
t_1 := -\frac{c}{b}\\
t_2 := \left(-b\right) - t_0\\
\mathbf{if}\;b \leq -3.96398836197757 \cdot 10^{+61}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{2 \cdot a}{t_2}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq 1.422349730838436 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_2}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{c}{t_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\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) (* (* a 4.0) c))))
(t_1 (- (/ c b)))
(t_2 (- (- b) t_0)))
(if (<= b -3.96398836197757e+61)
(if (>= b 0.0) (/ 1.0 (/ (* 2.0 a) t_2)) t_1)
(if (<= b 1.422349730838436e+93)
(if (>= b 0.0) (/ t_2 (* 2.0 a)) (* 2.0 (/ c (- t_0 b))))
(if (>= b 0.0) (- (/ c b) (/ b a)) t_1)))))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) - ((a * 4.0) * c));
double t_1 = -(c / b);
double t_2 = -b - t_0;
double tmp_1;
if (b <= -3.96398836197757e+61) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 1.0 / ((2.0 * a) / t_2);
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.422349730838436e+93) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2 / (2.0 * a);
} else {
tmp_3 = 2.0 * (c / (t_0 - b));
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_1;
}
return tmp_1;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -3.96398836197757e61Initial program 27.1
Taylor expanded in b around -inf 3.6
Applied clear-num_binary643.6
if -3.96398836197757e61 < b < 1.422349730838436e93Initial program 8.5
Applied *-un-lft-identity_binary648.5
Applied times-frac_binary648.5
if 1.422349730838436e93 < b Initial program 44.2
Taylor expanded in b around -inf 44.2
Taylor expanded in b around inf 4.2
Final simplification6.4
herbie shell --seed 2021275
(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)))))))