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



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -7.90697421919810219e158 or 1.575494962430441e134 < b Initial program 46.0
Simplified46.0
Taylor expanded around -inf 27.3
Simplified27.3
rmApplied *-un-lft-identity_binary6427.3
Applied times-frac_binary6424.5
Simplified24.5
Taylor expanded around inf 5.8
Simplified2.2
if -7.90697421919810219e158 < b < -8.2405720480971928e-292Initial program 7.6
Simplified7.6
rmApplied flip-+_binary647.6
Simplified7.6
if -8.2405720480971928e-292 < b < 1.575494962430441e134Initial program 9.3
Simplified9.4
rmApplied flip--_binary649.4
Simplified9.4
Simplified9.4
Final simplification6.6
herbie shell --seed 2020260
(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)))))))