\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.444790154581287 \cdot 10^{+129}:\\
\;\;\;\;\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(b - c \cdot \frac{a}{b}\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.5473348289606372 \cdot 10^{+103}:\\
\;\;\;\;\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:\\
\;\;\;\;-0.5 \cdot \frac{b + \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{a}\\
\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 -8.444790154581287e+129)
(if (>= b 0.0)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* (* 4.0 a) c)))) a))
(/ (* c -2.0) (* 2.0 (- b (* c (/ a b))))))
(if (<= b 1.5473348289606372e+103)
(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)
(* -0.5 (/ (+ b (- b (* 2.0 (/ (* a c) b)))) a))
(/ (* 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 <= -8.444790154581287e+129) {
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 * (b - (c * (a / b))));
}
tmp = tmp_1;
} else if (b <= 1.5473348289606372e+103) {
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 = -0.5 * ((b + (b - (2.0 * ((a * c) / b)))) / a);
} 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 < -8.4447901545812872e129Initial program 33.4
Simplified33.4
Taylor expanded around -inf 5.2
rmApplied frac-2neg_binary64_895.2
Simplified5.2
Simplified1.5
if -8.4447901545812872e129 < b < 1.54733482896063715e103Initial program 8.8
Simplified8.8
if 1.54733482896063715e103 < b Initial program 48.4
Simplified48.4
Taylor expanded around inf 9.0
Final simplification7.3
herbie shell --seed 2020342
(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)))))))