\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 -1.3526827374990375 \cdot 10^{+154}:\\
\;\;\;\;\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{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1407010824252603 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}} \cdot \sqrt{\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}{2 \cdot \left(b - \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 -1.3526827374990375e+154)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* c (* 4.0 a)))))))
(/ (* 2.0 (- (/ (* c a) b) b)) (* a 2.0)))
(if (<= b 1.1407010824252603e+105)
(if (>= b 0.0)
(*
-2.0
(/
c
(+
b
(*
(sqrt (sqrt (- (* b b) (* c (* 4.0 a)))))
(sqrt (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 (* 2.0 (- b (/ (* 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 <= -1.3526827374990375e+154) {
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)) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 1.1407010824252603e+105) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (sqrt(sqrt((b * b) - (c * (4.0 * a)))) * sqrt(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 / (2.0 * (b - ((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 < -1.3526827374990375e154Initial program 64.0
Simplified64.0
Taylor expanded around -inf 11.1
Simplified11.1
if -1.3526827374990375e154 < b < 1.1407010824252603e105Initial program 8.7
Simplified8.7
rmApplied add-sqr-sqrt_binary648.7
Applied sqrt-prod_binary648.8
if 1.1407010824252603e105 < b Initial program 30.0
Simplified30.0
rmApplied add-sqr-sqrt_binary6430.0
Applied sqrt-prod_binary6430.0
Taylor expanded around inf 6.6
Simplified6.6
Final simplification8.5
herbie shell --seed 2020220
(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))))