(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
:precision binary64
(if (<= b -7.863505383668454e+146)
(/ (/ (* b -2.0) 3.0) a)
(if (<= b 8.84535440633062e-68)
(/ (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) 3.0) a)
(* -0.5 (/ c b)))))double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
double tmp;
if (b <= -7.863505383668454e+146) {
tmp = ((b * -2.0) / 3.0) / a;
} else if (b <= 8.84535440633062e-68) {
tmp = ((sqrt(((b * b) - ((3.0 * a) * c))) - b) / 3.0) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
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) :: tmp
if (b <= (-7.863505383668454d+146)) then
tmp = ((b * (-2.0d0)) / 3.0d0) / a
else if (b <= 8.84535440633062d-68) then
tmp = ((sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / 3.0d0) / a
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.863505383668454e+146) {
tmp = ((b * -2.0) / 3.0) / a;
} else if (b <= 8.84535440633062e-68) {
tmp = ((Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / 3.0) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
def code(a, b, c): tmp = 0 if b <= -7.863505383668454e+146: tmp = ((b * -2.0) / 3.0) / a elif b <= 8.84535440633062e-68: tmp = ((math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / 3.0) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function code(a, b, c) tmp = 0.0 if (b <= -7.863505383668454e+146) tmp = Float64(Float64(Float64(b * -2.0) / 3.0) / a); elseif (b <= 8.84535440633062e-68) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / 3.0) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.863505383668454e+146) tmp = ((b * -2.0) / 3.0) / a; elseif (b <= 8.84535440633062e-68) tmp = ((sqrt(((b * b) - ((3.0 * a) * c))) - b) / 3.0) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := If[LessEqual[b, -7.863505383668454e+146], N[(N[(N[(b * -2.0), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 8.84535440633062e-68], N[(N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -7.863505383668454 \cdot 10^{+146}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\
\mathbf{elif}\;b \leq 8.84535440633062 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -7.8635053836684542e146Initial program 61.2
Applied associate-/r*_binary6461.2
Simplified37.2
Taylor expanded in b around -inf 2.9
if -7.8635053836684542e146 < b < 8.8453544063306207e-68Initial program 13.1
Applied associate-/r*_binary6413.2
if 8.8453544063306207e-68 < b Initial program 53.2
Taylor expanded in b around inf 8.5
Final simplification10.2
herbie shell --seed 2022138
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))