\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}
t_0 := \frac{b \cdot -2}{2 \cdot a}\\
t_1 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_2 := \frac{t_1 - b}{2 \cdot a}\\
t_3 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{-4 \cdot \left(c \cdot a\right)}, b\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := c \cdot \left(a \cdot -4\right)\\
\mathbf{if}\;t_3 \leq -8.592495155215768 \cdot 10^{-212}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, t_4\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;t_3 \leq 2.186239331089963 \cdot 10^{-227}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;t_3 \leq 7.877079281670829 \cdot 10^{+236}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{t_4}, b\right)}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\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
(let* ((t_0 (/ (* b -2.0) (* 2.0 a)))
(t_1 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_2 (/ (- t_1 b) (* 2.0 a)))
(t_3 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) t_2)))
(if (<= t_3 (- INFINITY))
(if (>= b 0.0)
(* 2.0 (/ c (- (- b) (hypot (sqrt (* -4.0 (* c a))) b))))
t_0)
(let* ((t_4 (* c (* a -4.0))))
(if (<= t_3 -8.592495155215768e-212)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (fma b b t_4)))) t_2)
(if (<= t_3 2.186239331089963e-227)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) t_2)
(if (<= t_3 7.877079281670829e+236)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (hypot (sqrt t_4) b))) t_2)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) t_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 t_0 = (b * -2.0) / (2.0 * a);
double t_1 = sqrt((b * b) - (c * (4.0 * a)));
double t_2 = (t_1 - b) / (2.0 * a);
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_1);
} else {
tmp = t_2;
}
double t_3 = tmp;
double tmp_2;
if (t_3 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 * (c / (-b - hypot(sqrt(-4.0 * (c * a)), b)));
} else {
tmp_3 = t_0;
}
tmp_2 = tmp_3;
} else {
double t_4 = c * (a * -4.0);
double tmp_5;
if (t_3 <= -8.592495155215768e-212) {
double tmp_6;
if (b >= 0.0) {
tmp_6 = (2.0 * c) / (-b - sqrt(fma(b, b, t_4)));
} else {
tmp_6 = t_2;
}
tmp_5 = tmp_6;
} else if (t_3 <= 2.186239331089963e-227) {
double tmp_7;
if (b >= 0.0) {
tmp_7 = (2.0 * c) / (-b - b);
} else {
tmp_7 = t_2;
}
tmp_5 = tmp_7;
} else if (t_3 <= 7.877079281670829e+236) {
double tmp_8;
if (b >= 0.0) {
tmp_8 = (2.0 * c) / (-b - hypot(sqrt(t_4), b));
} else {
tmp_8 = t_2;
}
tmp_5 = tmp_8;
} else if (b >= 0.0) {
tmp_5 = (2.0 * c) / (b * -2.0);
} else {
tmp_5 = t_0;
}
tmp_2 = tmp_5;
}
return tmp_2;
}



Bits error versus a



Bits error versus b



Bits error versus c
if (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -inf.0Initial program 64.0
Taylor expanded in b around -inf 16.4
Applied associate-/l*_binary6416.2
Simplified16.4
Applied div-inv_binary6416.4
Simplified16.2
if -inf.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -8.5924951552157676e-212Initial program 3.4
Applied fma-neg_binary643.4
Simplified3.4
if -8.5924951552157676e-212 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 2.18623933108996304e-227Initial program 30.0
Taylor expanded in b around inf 10.8
if 2.18623933108996304e-227 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 7.87707928167082875e236Initial program 2.7
Applied *-un-lft-identity_binary642.7
Applied sqrt-prod_binary642.7
Simplified2.7
Simplified8.3
if 7.87707928167082875e236 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) Initial program 51.7
Taylor expanded in b around -inf 18.3
Taylor expanded in b around inf 15.1
Final simplification8.8
herbie shell --seed 2021225
(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))))