(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 -8.620998372327297e+152)
(/ (* 2.0 (/ b -3.0)) a)
(if (<= b 4.913578702369731e-99)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ c (* b -2.0)))))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 <= -8.620998372327297e+152) {
tmp = (2.0 * (b / -3.0)) / a;
} else if (b <= 4.913578702369731e-99) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = c / (b * -2.0);
}
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 <= (-8.620998372327297d+152)) then
tmp = (2.0d0 * (b / (-3.0d0))) / a
else if (b <= 4.913578702369731d-99) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = c / (b * (-2.0d0))
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 <= -8.620998372327297e+152) {
tmp = (2.0 * (b / -3.0)) / a;
} else if (b <= 4.913578702369731e-99) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = c / (b * -2.0);
}
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 <= -8.620998372327297e+152: tmp = (2.0 * (b / -3.0)) / a elif b <= 4.913578702369731e-99: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = c / (b * -2.0) 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 <= -8.620998372327297e+152) tmp = Float64(Float64(2.0 * Float64(b / -3.0)) / a); elseif (b <= 4.913578702369731e-99) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(c / Float64(b * -2.0)); 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 <= -8.620998372327297e+152) tmp = (2.0 * (b / -3.0)) / a; elseif (b <= 4.913578702369731e-99) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = c / (b * -2.0); 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, -8.620998372327297e+152], N[(N[(2.0 * N[(b / -3.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.913578702369731e-99], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(c / N[(b * -2.0), $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 -8.620998372327297 \cdot 10^{+152}:\\
\;\;\;\;\frac{2 \cdot \frac{b}{-3}}{a}\\
\mathbf{elif}\;b \leq 4.913578702369731 \cdot 10^{-99}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b \cdot -2}\\
\end{array}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -8.62099837232729742e152Initial program 63.3
Applied flip-+_binary6464.0
Simplified62.7
Simplified64.0
Applied *-un-lft-identity_binary6464.0
Applied times-frac_binary6464.0
Applied times-frac_binary6464.0
Simplified64.0
Simplified64.0
Taylor expanded in b around -inf 56.1
Simplified3.1
if -8.62099837232729742e152 < b < 4.9135787023697313e-99Initial program 12.2
Applied *-commutative_binary6412.2
if 4.9135787023697313e-99 < b Initial program 52.9
Applied flip-+_binary6452.9
Simplified25.5
Simplified33.9
Applied *-un-lft-identity_binary6433.9
Applied times-frac_binary6433.8
Applied times-frac_binary6433.8
Simplified33.8
Simplified33.8
Applied *-un-lft-identity_binary6433.8
Applied *-un-lft-identity_binary6433.8
Applied times-frac_binary6433.8
Simplified33.8
Simplified27.5
Taylor expanded in b around inf 9.5
Simplified9.5
Final simplification10.1
herbie shell --seed 2022137
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))