\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}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\
\end{array} \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\
\end{array}\\
\mathbf{elif}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\
\end{array} \leq -1.0805702848075502 \cdot 10^{-217}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\
\end{array}\\
\mathbf{elif}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\
\end{array} \leq 1.5319276799111174 \cdot 10^{-228}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{1}{\frac{a}{\frac{4 \cdot \left(a \cdot c\right)}{b - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\
\end{array} \leq 2.8818617001689194 \cdot 10^{+228}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\
\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 \left(2 \cdot \left(\frac{b}{a} - \frac{c}{b}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\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 (<=
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* a 2.0))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
(- INFINITY))
(if (>= b 0.0)
(* -0.5 (/ (+ b b) a))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
(if (<=
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* a 2.0))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
-1.0805702848075502e-217)
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* a 2.0))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
(if (<=
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* a 2.0))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
1.5319276799111174e-228)
(if (>= b 0.0)
(*
-0.5
(/
1.0
(/ a (/ (* 4.0 (* a c)) (- b (sqrt (- (* b b) (* 4.0 (* a c)))))))))
(/ (* c 2.0) (- (- b) b)))
(if (<=
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* a 2.0))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
2.8818617001689194e+228)
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* a 2.0))
(/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
(if (>= b 0.0)
(* -0.5 (* 2.0 (- (/ b a) (/ c b))))
(/ (* c 2.0) (- (- b) 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_1;
if (b >= 0.0) {
tmp_1 = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (a * 2.0);
} else {
tmp_1 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
double tmp;
if (tmp_1 <= -((double) INFINITY)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * ((b + b) / a);
} else {
tmp_2 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
tmp = tmp_2;
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
} else if (tmp_3 <= -1.0805702848075502e-217) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (a * 2.0);
} else {
tmp_4 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
tmp = tmp_4;
double tmp_5;
if (b >= 0.0) {
tmp_5 = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (a * 2.0);
} else {
tmp_5 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
} else if (tmp_5 <= 1.5319276799111174e-228) {
double tmp_6;
if (b >= 0.0) {
tmp_6 = -0.5 * (1.0 / (a / ((4.0 * (a * c)) / (b - sqrt((b * b) - (4.0 * (a * c)))))));
} else {
tmp_6 = (c * 2.0) / (-b - b);
}
tmp = tmp_6;
double tmp_7;
if (b >= 0.0) {
tmp_7 = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (a * 2.0);
} else {
tmp_7 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
} else if (tmp_7 <= 2.8818617001689194e+228) {
double tmp_8;
if (b >= 0.0) {
tmp_8 = (-b - sqrt((b * b) - ((4.0 * a) * c))) / (a * 2.0);
} else {
tmp_8 = (c * 2.0) / (sqrt((b * b) - ((4.0 * a) * c)) - b);
}
tmp = tmp_8;
} else if (b >= 0.0) {
tmp = -0.5 * (2.0 * ((b / a) - (c / b)));
} else {
tmp = (c * 2.0) / (-b - b);
}
return tmp;
}



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.0Initial program 64.0
Simplified64.0
Taylor expanded around inf 18.5
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)))))) < -1.0805702848075502e-217 or 1.5319276799111174e-228 < (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)))))) < 2.88186170016891938e228Initial program 3.0
if -1.0805702848075502e-217 < (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)))))) < 1.5319276799111174e-228Initial program 30.6
Simplified30.6
Taylor expanded around -inf 10.3
Simplified10.3
rmApplied clear-num_binary64_7710.3
Simplified10.3
rmApplied flip-+_binary64_5210.6
Simplified10.6
if 2.88186170016891938e228 < (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 51.0
Simplified51.0
Taylor expanded around -inf 48.4
Simplified48.4
Taylor expanded around inf 15.3
Simplified15.3
Final simplification7.5
herbie shell --seed 2021023
(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)))))))