\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}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
t_2 := \frac{c \cdot 2}{\left(-b\right) - b}\\
t_3 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_1 \leq -9.915702647006648 \cdot 10^{-258}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\begin{array}{l}
t_4 := \sqrt{b + \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -4\right)}, b\right)}\\
-0.5 \cdot \left(t_4 \cdot \frac{t_4}{a}\right)
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;t_1 \leq 5.305809263431213 \cdot 10^{+253}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\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
(let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b))))
(t_2 (/ (* c 2.0) (- (- b) b)))
(t_3 (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) t_2)))
(if (<= t_1 (- INFINITY))
t_3
(if (<= t_1 -9.915702647006648e-258)
t_1
(if (<= t_1 0.0)
(if (>= b 0.0)
(let* ((t_4 (sqrt (+ b (hypot (sqrt (* c (* a -4.0))) b)))))
(* -0.5 (* t_4 (/ t_4 a))))
t_2)
(if (<= t_1 5.305809263431213e+253) t_1 t_3))))))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 t_0 = sqrt((b * b) - ((4.0 * a) * c));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (a * 2.0);
} else {
tmp = (c * 2.0) / (t_0 - b);
}
double t_1 = tmp;
double t_2 = (c * 2.0) / (-b - b);
double tmp_1;
if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = t_2;
}
double t_3 = tmp_1;
double tmp_2;
if (t_1 <= -((double) INFINITY)) {
tmp_2 = t_3;
} else if (t_1 <= -9.915702647006648e-258) {
tmp_2 = t_1;
} else if (t_1 <= 0.0) {
double tmp_3;
if (b >= 0.0) {
double t_4_4 = sqrt(b + hypot(sqrt(c * (a * -4.0)), b));
tmp_3 = -0.5 * (t_4_4 * (t_4_4 / a));
} else {
tmp_3 = t_2;
}
tmp_2 = tmp_3;
} else if (t_1 <= 5.305809263431213e+253) {
tmp_2 = t_1;
} else {
tmp_2 = t_3;
}
return tmp_2;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -inf.0 or 5.3058092634312132e253 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) Initial program 59.7
Simplified59.6
Taylor expanded in b around -inf 56.9
Taylor expanded in a around 0 15.1
if -inf.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -9.91570264700664773e-258 or -0.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < 5.3058092634312132e253Initial program 2.6
if -9.91570264700664773e-258 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -0.0Initial program 36.2
Simplified36.2
Taylor expanded in b around -inf 10.0
Applied *-un-lft-identity_binary6410.0
Applied add-sqr-sqrt_binary6410.0
Applied times-frac_binary6410.0
Simplified10.0
Simplified10.0
Final simplification6.3
herbie shell --seed 2021344
(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)))))))