\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 -8.403599521210245 \cdot 10^{+110} \lor \neg \left(b \leq 2.1413501573873043 \cdot 10^{+105}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \left(b - 2 \cdot \frac{a}{\frac{b}{c}}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{\frac{b}{c}} - b\right)}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}} \cdot \sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{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 -8.403599521210245e+110) (not (<= b 2.1413501573873043e+105)))
(if (>= b 0.0)
(* -0.5 (/ (+ b (- b (* 2.0 (/ a (/ b c))))) a))
(/ (* 2.0 c) (* 2.0 (- (/ a (/ b c)) b))))
(if (>= b 0.0)
(*
-0.5
(/
(+
b
(*
(sqrt (sqrt (- (* b b) (* c (* a 4.0)))))
(sqrt (sqrt (- (* b b) (* c (* a 4.0)))))))
a))
(/ (* 2.0 c) (- (sqrt (- (* 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 <= -8.403599521210245e+110) || !(b <= 2.1413501573873043e+105)) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = -0.5 * ((b + (b - (2.0 * (a / (b / c))))) / a);
} else {
tmp_1 = (2.0 * c) / (2.0 * ((a / (b / c)) - b));
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = -0.5 * ((b + (sqrt(sqrt((b * b) - (c * (a * 4.0)))) * sqrt(sqrt((b * b) - (c * (a * 4.0)))))) / a);
} else {
tmp = (2.0 * c) / (sqrt((b * b) - (c * (a * 4.0))) - b);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -8.40359952121024462e110 or 2.14135015738730429e105 < b Initial program 38.2
Simplified38.2
Taylor expanded around -inf 23.9
Simplified23.9
rmApplied associate-/l*_binary6421.2
Taylor expanded around inf 5.7
Simplified2.7
if -8.40359952121024462e110 < b < 2.14135015738730429e105Initial program 9.2
Simplified9.2
rmApplied add-sqr-sqrt_binary649.2
Applied sqrt-prod_binary649.4
Final simplification6.9
herbie shell --seed 2020220
(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)))))))