\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}\begin{array}{l}
\mathbf{if}\;b \leq -3.8179933739837244 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 9.341172344491133 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\end{array}(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
:precision binary64
(if (<= b -3.8179933739837244e+151)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* c (* 4.0 a)))))))
(/ (- (- b) b) (* a 2.0)))
(if (<= b 9.341172344491133e+151)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (sqrt (- (* b b) (* c (* 4.0 a)))))))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0)))
(if (>= b 0.0)
(* -2.0 (/ c (* b 2.0)))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0))))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - sqrt((b * b) - ((4.0 * a) * c)));
} else {
tmp = (-b + sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
}
return tmp;
}
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8179933739837244e+151) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = -2.0 * (c / (b + sqrt((b * b) - (c * (4.0 * a)))));
} else {
tmp_1 = (-b - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 9.341172344491133e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + sqrt((b * b) - (c * (4.0 * a)))));
} else {
tmp_2 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (a * 2.0);
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = -2.0 * (c / (b * 2.0));
} else {
tmp = (sqrt((b * b) - (c * (4.0 * a))) - b) / (a * 2.0);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -3.8179933739837244e151Initial program 62.6
Simplified62.6
Taylor expanded around -inf 2.5
Simplified2.5
if -3.8179933739837244e151 < b < 9.34117234449113307e151Initial program 8.5
Simplified8.5
rmApplied *-un-lft-identity_binary648.5
if 9.34117234449113307e151 < b Initial program 38.9
Simplified38.9
Taylor expanded around inf 2.3
Simplified2.3
Final simplification6.7
herbie shell --seed 2021110
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))