\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 -9.753618941686308 \cdot 10^{+113}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.3534209732535931 \cdot 10^{+128}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b - 2 \cdot \frac{c \cdot a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\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 -9.753618941686308e+113)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* c (* 4.0 a)))))))
(/ (* b -2.0) (* a 2.0)))
(if (<= b 1.3534209732535931e+128)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* c (* 4.0 a)))))))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0)))
(if (>= b 0.0)
(* -2.0 (/ c (+ b (- b (* 2.0 (/ (* c a) b))))))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0))))))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 <= -9.753618941686308e+113) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = -2.0 * (c / (b + sqrt((b * b) - (c * (4.0 * a)))));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 1.3534209732535931e+128) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + sqrt((b * b) - (c * (4.0 * a)))));
} else {
tmp_2 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (a * 2.0);
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = -2.0 * (c / (b + (b - (2.0 * ((c * a) / b)))));
} else {
tmp = (sqrt((b * b) - (c * (4.0 * a))) - b) / (a * 2.0);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -9.75361894168630822e113Initial program 51.6
Simplified51.6
rmApplied add-exp-log_binary6452.8
Taylor expanded around -inf 9.8
Simplified3.3
if -9.75361894168630822e113 < b < 1.35342097325359313e128Initial program 8.7
Simplified8.7
if 1.35342097325359313e128 < b Initial program 34.2
Simplified34.2
Taylor expanded around inf 6.4
Simplified6.4
Final simplification7.5
herbie shell --seed 2020289
(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))))