\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 -3.281222392987421 \cdot 10^{+142} \lor \neg \left(b \leq 8.332598834170677 \cdot 10^{+99}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{2 \cdot \left(b - \frac{c}{b} \cdot a\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\sqrt[3]{b}} - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left|\sqrt[3]{b \cdot b - c \cdot \left(a \cdot 4\right)}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - c \cdot \left(a \cdot 4\right)}} - 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 (or (<= b -3.281222392987421e+142) (not (<= b 8.332598834170677e+99)))
(if (>= b 0.0)
(* -0.5 (/ (* 2.0 (- b (* (/ c b) a))) a))
(/ c (- (* (/ a (* (cbrt b) (cbrt b))) (/ c (cbrt b))) b)))
(if (>= b 0.0)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* c (* a 4.0))))) a))
(/
(* 2.0 c)
(-
(*
(fabs (cbrt (- (* b b) (* c (* a 4.0)))))
(sqrt (cbrt (- (* b b) (* c (* a 4.0))))))
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 <= -3.281222392987421e+142) || !(b <= 8.332598834170677e+99)) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = -0.5 * ((2.0 * (b - ((c / b) * a))) / a);
} else {
tmp_1 = c / (((a / (cbrt(b) * cbrt(b))) * (c / cbrt(b))) - b);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = -0.5 * ((b + sqrt((b * b) - (c * (a * 4.0)))) / a);
} else {
tmp = (2.0 * c) / ((fabs(cbrt((b * b) - (c * (a * 4.0)))) * sqrt(cbrt((b * b) - (c * (a * 4.0))))) - b);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -3.28122239298742125e142 or 8.3325988341706774e99 < b Initial program 40.8
Simplified40.8
Taylor expanded around -inf 23.9
Simplified23.9
rmApplied add-cube-cbrt_binary64_10923.9
Applied times-frac_binary64_8321.2
rmApplied associate-/r*_binary64_2321.0
Simplified21.0
Taylor expanded around inf 5.6
Simplified2.7
if -3.28122239298742125e142 < b < 8.3325988341706774e99Initial program 8.3
Simplified8.3
rmApplied add-cube-cbrt_binary64_1098.5
Applied sqrt-prod_binary64_928.5
Simplified8.5
Final simplification6.5
herbie shell --seed 2020303
(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)))))))