\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}\begin{array}{l}
\mathbf{if}\;b \leq -3.0466010076614915 \cdot 10^{+99}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(2 \cdot \frac{c \cdot a}{b} - b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 6.155701145742715 \cdot 10^{+138}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
:precision binary64
(if (<= b -3.0466010076614915e+99)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
(/ (- (- (* 2.0 (/ (* c a) b)) b) b) (* 2.0 a)))
(if (<= b 6.155701145742715e+138)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
(/
(-
(*
(fabs (cbrt (- (* b b) (* c (* 4.0 a)))))
(sqrt (cbrt (- (* b b) (* c (* 4.0 a))))))
b)
(* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (/ (* c a) b) b)))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a))))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - sqrt((b * b) - ((4.0 * a) * c)));
} else {
tmp = (-b + sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
}
return tmp;
}
double code(double a, double b, double c) {
double tmp;
if (b <= -3.0466010076614915e+99) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
} else {
tmp_1 = (((2.0 * ((c * a) / b)) - b) - b) / (2.0 * a);
}
tmp = tmp_1;
} else if (b <= 6.155701145742715e+138) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
} else {
tmp_2 = ((fabs(cbrt((b * b) - (c * (4.0 * a)))) * sqrt(cbrt((b * b) - (c * (4.0 * a))))) - b) / (2.0 * a);
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * (((c * a) / b) - b));
} else {
tmp = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -3.0466010076614915e99Initial program 46.7
Taylor expanded around -inf 9.3
if -3.0466010076614915e99 < b < 6.15570114574271503e138Initial program 8.7
rmApplied add-cube-cbrt_binary648.9
Applied sqrt-prod_binary648.9
Simplified8.9
if 6.15570114574271503e138 < b Initial program 34.8
rmApplied add-sqr-sqrt_binary6434.8
Taylor expanded around inf 6.8
Simplified6.8
Final simplification8.5
herbie shell --seed 2020268
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))