(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) (* c (* a -4.0)))))
(t_1 (/ (- (- b) t_0) (* a 2.0)))
(t_2 (/ (* c 2.0) (- t_0 b))))
(if (<= b -1.7e+143)
(if (>= b 0.0) t_1 (/ (- c) b))
(if (<= b 8.6e+111)
(if (>= b 0.0) t_1 t_2)
(if (>= b 0.0) (- (/ (+ b b) (* a 2.0))) t_2)))))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) + (c * (a * -4.0))));
double t_1 = (-b - t_0) / (a * 2.0);
double t_2 = (c * 2.0) / (t_0 - b);
double tmp_1;
if (b <= -1.7e+143) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 8.6e+111) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -((b + b) / (a * 2.0));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (-b - sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + sqrt(((b * b) - ((4.0d0 * a) * c))))
end if
code = tmp
end function
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) + (c * (a * (-4.0d0)))))
t_1 = (-b - t_0) / (a * 2.0d0)
t_2 = (c * 2.0d0) / (t_0 - b)
if (b <= (-1.7d+143)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 8.6d+111) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = t_2
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = -((b + b) / (a * 2.0d0))
else
tmp_1 = t_2
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + Math.sqrt(((b * b) - ((4.0 * a) * c))));
}
return tmp;
}
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) + (c * (a * -4.0))));
double t_1 = (-b - t_0) / (a * 2.0);
double t_2 = (c * 2.0) / (t_0 - b);
double tmp_1;
if (b <= -1.7e+143) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 8.6e+111) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -((b + b) / (a * 2.0));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a) else: tmp = (2.0 * c) / (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) return tmp
def code(a, b, c): t_0 = math.sqrt(((b * b) + (c * (a * -4.0)))) t_1 = (-b - t_0) / (a * 2.0) t_2 = (c * 2.0) / (t_0 - b) tmp_1 = 0 if b <= -1.7e+143: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 8.6e+111: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = t_2 tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -((b + b) / (a * 2.0)) else: tmp_1 = t_2 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))))); end return tmp end
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))) t_1 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)) t_2 = Float64(Float64(c * 2.0) / Float64(t_0 - b)) tmp_1 = 0.0 if (b <= -1.7e+143) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 8.6e+111) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))); else tmp_1 = t_2; end return tmp_1 end
function tmp_2 = code(a, b, c) tmp = 0.0; 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)))); end tmp_2 = tmp; end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) + (c * (a * -4.0)))); t_1 = (-b - t_0) / (a * 2.0); t_2 = (c * 2.0) / (t_0 - b); tmp_2 = 0.0; if (b <= -1.7e+143) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 8.6e+111) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = t_2; end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -((b + b) / (a * 2.0)); else tmp_2 = t_2; end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.7e+143], If[GreaterEqual[b, 0.0], t$95$1, N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 8.6e+111], If[GreaterEqual[b, 0.0], t$95$1, t$95$2], If[GreaterEqual[b, 0.0], (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), t$95$2]]]]]]
\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 + c \cdot \left(a \cdot -4\right)}\\
t_1 := \frac{\left(-b\right) - t_0}{a \cdot 2}\\
t_2 := \frac{c \cdot 2}{t_0 - b}\\
\mathbf{if}\;b \leq -1.7 \cdot 10^{+143}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+111}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-\frac{b + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -1.69999999999999991e143Initial program 36.0
Taylor expanded in b around -inf 1.5
if -1.69999999999999991e143 < b < 8.59999999999999987e111Initial program 8.6
if 8.59999999999999987e111 < b Initial program 51.2
Taylor expanded in b around inf 4.6
Final simplification6.7
herbie shell --seed 2022156
(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)))))))