
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
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
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
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 tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); 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]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
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
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
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 tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); 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]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -3.1e+94)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.55e-128)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.1e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.55e-128) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-3.1d+94)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.55d-128) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.1e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.55e-128) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.1e+94: tmp = (b * -0.6666666666666666) / a elif b <= 2.55e-128: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.1e+94) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.55e-128) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.1e+94) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.55e-128) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.1e+94], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.55e-128], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.1 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.09999999999999991e94Initial program 52.9%
sqr-neg52.9%
sqr-neg52.9%
associate-*l*52.9%
Simplified52.9%
Taylor expanded in b around -inf 99.7%
*-commutative99.7%
Simplified99.7%
associate-*l/99.8%
Applied egg-rr99.8%
if -3.09999999999999991e94 < b < 2.5500000000000002e-128Initial program 84.7%
if 2.5500000000000002e-128 < b Initial program 14.1%
add-cube-cbrt14.0%
pow314.0%
Applied egg-rr14.0%
Taylor expanded in b around inf 87.6%
*-commutative87.6%
rem-cube-cbrt88.3%
associate-/l*88.3%
Simplified88.3%
*-commutative88.3%
associate-*r/88.3%
associate-*r/88.5%
Applied egg-rr88.5%
*-commutative88.5%
associate-*l*88.8%
metadata-eval88.8%
Simplified88.8%
Final simplification89.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9e+94)
(/ (* b -0.6666666666666666) a)
(if (<= b 3.8e-128)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.8e-128) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-9d+94)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 3.8d-128) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.8e-128) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e+94: tmp = (b * -0.6666666666666666) / a elif b <= 3.8e-128: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e+94) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 3.8e-128) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9e+94) tmp = (b * -0.6666666666666666) / a; elseif (b <= 3.8e-128) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e+94], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.8e-128], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8.99999999999999944e94Initial program 52.9%
sqr-neg52.9%
sqr-neg52.9%
associate-*l*52.9%
Simplified52.9%
Taylor expanded in b around -inf 99.7%
*-commutative99.7%
Simplified99.7%
associate-*l/99.8%
Applied egg-rr99.8%
if -8.99999999999999944e94 < b < 3.8000000000000002e-128Initial program 84.7%
sqr-neg84.7%
sqr-neg84.7%
associate-*l*84.6%
Simplified84.6%
if 3.8000000000000002e-128 < b Initial program 14.1%
add-cube-cbrt14.0%
pow314.0%
Applied egg-rr14.0%
Taylor expanded in b around inf 87.6%
*-commutative87.6%
rem-cube-cbrt88.3%
associate-/l*88.3%
Simplified88.3%
*-commutative88.3%
associate-*r/88.3%
associate-*r/88.5%
Applied egg-rr88.5%
*-commutative88.5%
associate-*l*88.8%
metadata-eval88.8%
Simplified88.8%
Final simplification89.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.8e-80)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 3.8e-128)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.8e-80) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 3.8e-128) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-1.8d-80)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 3.8d-128) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.8e-80) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 3.8e-128) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.8e-80: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 3.8e-128: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.8e-80) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 3.8e-128) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.8e-80) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 3.8e-128) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.8e-80], N[(b * N[(N[(0.6666666666666666 * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-128], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-80}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.8e-80Initial program 68.8%
sqr-neg68.8%
sqr-neg68.8%
associate-*l*68.8%
Simplified68.8%
Taylor expanded in b around -inf 84.6%
if -1.8e-80 < b < 3.8000000000000002e-128Initial program 79.4%
sqr-neg79.4%
sqr-neg79.4%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in b around 0 74.8%
associate-*r*74.9%
*-commutative74.9%
Simplified74.9%
if 3.8000000000000002e-128 < b Initial program 14.1%
add-cube-cbrt14.0%
pow314.0%
Applied egg-rr14.0%
Taylor expanded in b around inf 87.6%
*-commutative87.6%
rem-cube-cbrt88.3%
associate-/l*88.3%
Simplified88.3%
*-commutative88.3%
associate-*r/88.3%
associate-*r/88.5%
Applied egg-rr88.5%
*-commutative88.5%
associate-*l*88.8%
metadata-eval88.8%
Simplified88.8%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.3e-80)
(* -0.6666666666666666 (/ b a))
(if (<= b 3.1e-128)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.3e-80) {
tmp = -0.6666666666666666 * (b / a);
} else if (b <= 3.1e-128) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-1.3d-80)) then
tmp = (-0.6666666666666666d0) * (b / a)
else if (b <= 3.1d-128) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.3e-80) {
tmp = -0.6666666666666666 * (b / a);
} else if (b <= 3.1e-128) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.3e-80: tmp = -0.6666666666666666 * (b / a) elif b <= 3.1e-128: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.3e-80) tmp = Float64(-0.6666666666666666 * Float64(b / a)); elseif (b <= 3.1e-128) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.3e-80) tmp = -0.6666666666666666 * (b / a); elseif (b <= 3.1e-128) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.3e-80], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e-128], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \cdot 10^{-80}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.3e-80Initial program 68.8%
sqr-neg68.8%
sqr-neg68.8%
associate-*l*68.8%
Simplified68.8%
Taylor expanded in b around -inf 84.5%
*-commutative84.5%
Simplified84.5%
if -1.3e-80 < b < 3.10000000000000003e-128Initial program 79.4%
sqr-neg79.4%
sqr-neg79.4%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in b around 0 74.8%
associate-*r*74.9%
*-commutative74.9%
Simplified74.9%
if 3.10000000000000003e-128 < b Initial program 14.1%
add-cube-cbrt14.0%
pow314.0%
Applied egg-rr14.0%
Taylor expanded in b around inf 87.6%
*-commutative87.6%
rem-cube-cbrt88.3%
associate-/l*88.3%
Simplified88.3%
*-commutative88.3%
associate-*r/88.3%
associate-*r/88.5%
Applied egg-rr88.5%
*-commutative88.5%
associate-*l*88.8%
metadata-eval88.8%
Simplified88.8%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -8.8e-80)
(* -0.6666666666666666 (/ b a))
(if (<= b 3.8e-128)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-80) {
tmp = -0.6666666666666666 * (b / a);
} else if (b <= 3.8e-128) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-8.8d-80)) then
tmp = (-0.6666666666666666d0) * (b / a)
else if (b <= 3.8d-128) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-80) {
tmp = -0.6666666666666666 * (b / a);
} else if (b <= 3.8e-128) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.8e-80: tmp = -0.6666666666666666 * (b / a) elif b <= 3.8e-128: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.8e-80) tmp = Float64(-0.6666666666666666 * Float64(b / a)); elseif (b <= 3.8e-128) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.8e-80) tmp = -0.6666666666666666 * (b / a); elseif (b <= 3.8e-128) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.8e-80], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-128], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.8 \cdot 10^{-80}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8.80000000000000041e-80Initial program 68.8%
sqr-neg68.8%
sqr-neg68.8%
associate-*l*68.8%
Simplified68.8%
Taylor expanded in b around -inf 84.5%
*-commutative84.5%
Simplified84.5%
if -8.80000000000000041e-80 < b < 3.8000000000000002e-128Initial program 79.4%
sqr-neg79.4%
sqr-neg79.4%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in b around 0 74.8%
if 3.8000000000000002e-128 < b Initial program 14.1%
add-cube-cbrt14.0%
pow314.0%
Applied egg-rr14.0%
Taylor expanded in b around inf 87.6%
*-commutative87.6%
rem-cube-cbrt88.3%
associate-/l*88.3%
Simplified88.3%
*-commutative88.3%
associate-*r/88.3%
associate-*r/88.5%
Applied egg-rr88.5%
*-commutative88.5%
associate-*l*88.8%
metadata-eval88.8%
Simplified88.8%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-142)
(* -0.6666666666666666 (/ b a))
(if (<= b 9.8e-141)
(- (sqrt (* (* -3.0 (/ c a)) 0.1111111111111111)))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-142) {
tmp = -0.6666666666666666 * (b / a);
} else if (b <= 9.8e-141) {
tmp = -sqrt(((-3.0 * (c / a)) * 0.1111111111111111));
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-3.6d-142)) then
tmp = (-0.6666666666666666d0) * (b / a)
else if (b <= 9.8d-141) then
tmp = -sqrt((((-3.0d0) * (c / a)) * 0.1111111111111111d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-142) {
tmp = -0.6666666666666666 * (b / a);
} else if (b <= 9.8e-141) {
tmp = -Math.sqrt(((-3.0 * (c / a)) * 0.1111111111111111));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.6e-142: tmp = -0.6666666666666666 * (b / a) elif b <= 9.8e-141: tmp = -math.sqrt(((-3.0 * (c / a)) * 0.1111111111111111)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-142) tmp = Float64(-0.6666666666666666 * Float64(b / a)); elseif (b <= 9.8e-141) tmp = Float64(-sqrt(Float64(Float64(-3.0 * Float64(c / a)) * 0.1111111111111111))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.6e-142) tmp = -0.6666666666666666 * (b / a); elseif (b <= 9.8e-141) tmp = -sqrt(((-3.0 * (c / a)) * 0.1111111111111111)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-142], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.8e-141], (-N[Sqrt[N[(N[(-3.0 * N[(c / a), $MachinePrecision]), $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-142}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-141}:\\
\;\;\;\;-\sqrt{\left(-3 \cdot \frac{c}{a}\right) \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.6e-142Initial program 71.0%
sqr-neg71.0%
sqr-neg71.0%
associate-*l*70.9%
Simplified70.9%
Taylor expanded in b around -inf 79.3%
*-commutative79.3%
Simplified79.3%
if -3.6e-142 < b < 9.80000000000000012e-141Initial program 75.8%
add-cube-cbrt75.2%
pow375.2%
Applied egg-rr75.2%
Taylor expanded in a around -inf 0.0%
associate-*r*0.0%
rem-cube-cbrt0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt28.6%
Simplified28.6%
add-sqr-sqrt0.8%
sqrt-unprod41.5%
*-commutative41.5%
*-commutative41.5%
swap-sqr41.4%
add-sqr-sqrt41.5%
associate-*r/41.6%
*-commutative41.6%
associate-/l*41.5%
metadata-eval41.5%
Applied egg-rr41.5%
if 9.80000000000000012e-141 < b Initial program 16.3%
add-cube-cbrt16.3%
pow316.3%
Applied egg-rr16.3%
Taylor expanded in b around inf 85.4%
*-commutative85.4%
rem-cube-cbrt86.1%
associate-/l*86.1%
Simplified86.1%
*-commutative86.1%
associate-*r/86.1%
associate-*r/86.3%
Applied egg-rr86.3%
*-commutative86.3%
associate-*l*86.6%
metadata-eval86.6%
Simplified86.6%
Final simplification75.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / 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
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in b around -inf 66.0%
*-commutative66.0%
Simplified66.0%
if -4.999999999999985e-310 < b Initial program 24.5%
add-cube-cbrt24.3%
pow324.4%
Applied egg-rr24.4%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
rem-cube-cbrt73.2%
associate-/l*73.2%
Simplified73.2%
*-commutative73.2%
associate-*r/73.2%
associate-*r/73.4%
Applied egg-rr73.4%
*-commutative73.4%
associate-*l*73.7%
metadata-eval73.7%
Simplified73.7%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / 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
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in b around -inf 66.0%
*-commutative66.0%
Simplified66.0%
if -4.999999999999985e-310 < b Initial program 24.5%
sqr-neg24.5%
sqr-neg24.5%
associate-*l*24.5%
Simplified24.5%
Taylor expanded in b around inf 73.7%
*-commutative73.7%
Simplified73.7%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 47.5%
sqr-neg47.5%
sqr-neg47.5%
associate-*l*47.5%
Simplified47.5%
Taylor expanded in b around -inf 31.9%
*-commutative31.9%
Simplified31.9%
Final simplification31.9%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 47.5%
add-cube-cbrt47.3%
pow347.3%
Applied egg-rr47.3%
Taylor expanded in b around -inf 31.9%
associate-*r/31.9%
*-commutative31.9%
associate-/l*31.9%
Simplified31.9%
herbie shell --seed 2024114
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))