\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 -2.681333306749349 \cdot 10^{+149}:\\
\;\;\;\;\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(-b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.778748242798635 \cdot 10^{+68}:\\
\;\;\;\;\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{\sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} \cdot \sqrt{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}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}} \cdot \sqrt{\sqrt{b \cdot b - 4 \cdot \left(c \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 -2.681333306749349e+149)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
(/ (- (- b) b) (* 2.0 a)))
(if (<= b 2.778748242798635e+68)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
(/
(-
(sqrt
(*
(sqrt (- (* b b) (* c (* 4.0 a))))
(sqrt (- (* b b) (* c (* 4.0 a))))))
b)
(* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) b))
(/
(-
(*
(sqrt (sqrt (- (* b b) (* 4.0 (* c a)))))
(sqrt (sqrt (- (* b b) (* 4.0 (* c 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 <= -2.681333306749349e+149) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
} else {
tmp_1 = (-b - b) / (2.0 * a);
}
tmp = tmp_1;
} else if (b <= 2.778748242798635e+68) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
} else {
tmp_2 = (sqrt(sqrt((b * b) - (c * (4.0 * a))) * sqrt((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (-b - b);
} else {
tmp = ((sqrt(sqrt((b * b) - (4.0 * (c * a)))) * sqrt(sqrt((b * b) - (4.0 * (c * a))))) - b) / (2.0 * a);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -2.6813333067493492e149Initial program 61.9
Taylor expanded around -inf 2.4
Simplified2.4
if -2.6813333067493492e149 < b < 2.7787482427986349e68Initial program 9.2
rmApplied add-sqr-sqrt_binary649.2
if 2.7787482427986349e68 < b Initial program 26.5
rmApplied add-sqr-sqrt_binary6426.5
Simplified26.5
Simplified26.5
Taylor expanded around inf 3.2
Final simplification6.9
herbie shell --seed 2021118
(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))))