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



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -1.86050021910619632e136Initial program 34.9
Simplified34.9
rmApplied add-sqr-sqrt_binary6434.9
Taylor expanded around -inf 6.0
Simplified6.0
if -1.86050021910619632e136 < b < 6.03465117471632367e148Initial program 8.7
Simplified8.7
if 6.03465117471632367e148 < b Initial program 61.9
Taylor expanded around inf 11.5
Final simplification8.5
herbie shell --seed 2020273
(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)))))))