\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 -2.4202304013350694 \cdot 10^{+100} \lor \neg \left(b \leq 1.2920436183135944 \cdot 10^{+99}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\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 -2.4202304013350694e+100) (not (<= b 1.2920436183135944e+99)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (- (/ c b)))
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* c (* a 4.0))))) (* a 2.0))
(/ (* c 2.0) (- (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 <= -2.4202304013350694e+100) || !(b <= 1.2920436183135944e+99)) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = -(c / b);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (-b - sqrt((b * b) - (c * (a * 4.0)))) / (a * 2.0);
} else {
tmp = (c * 2.0) / (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 < -2.42023040133506939e100 or 1.29204361831359445e99 < b Initial program 37.1
Taylor expanded around inf 22.6
Taylor expanded around 0 19.9
rmApplied associate-/l*_binary64_2420.0
Simplified20.0
Taylor expanded around -inf 3.2
Simplified3.2
if -2.42023040133506939e100 < b < 1.29204361831359445e99Initial program 9.2
Final simplification6.8
herbie shell --seed 2020281
(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)))))))