
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\sqrt[3]{\frac{g}{2 \cdot a}}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\sqrt[3]{\frac{g}{2 \cdot a}}
(FPCore (g a) :precision binary64 (/ (cbrt (* 0.5 g)) (cbrt a)))
double code(double g, double a) {
return cbrt((0.5 * g)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(0.5 * g)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{a}}
Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (* 1.2599210498948732 (cbrt a))))
double code(double g, double a) {
return cbrt(g) / (1.2599210498948732 * cbrt(a));
}
public static double code(double g, double a) {
return Math.cbrt(g) / (1.2599210498948732 * Math.cbrt(a));
}
function code(g, a) return Float64(cbrt(g) / Float64(1.2599210498948732 * cbrt(a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[(1.2599210498948732 * N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\sqrt[3]{g}}{1.2599210498948732 \cdot \sqrt[3]{a}}
Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lift-*.f64N/A
*-commutativeN/A
cbrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f6475.0
Applied rewrites75.0%
Evaluated real constant75.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (* (cbrt (/ 0.5 a)) (cbrt g)))
double code(double g, double a) {
return cbrt((0.5 / a)) * cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) * Math.cbrt(g);
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) * cbrt(g)) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (+ a a))))
double code(double g, double a) {
return cbrt(g) / cbrt((a + a));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a + a));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a + a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}
Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (g a)
:precision binary64
(let* ((t_0 (/ 2.0 (fabs g))) (t_1 (cbrt (/ (fabs g) (* 2.0 (fabs a))))))
(*
(copysign 1.0 g)
(*
(copysign 1.0 a)
(if (<= t_1 4e-106)
(exp (* (+ (log t_0) (log (fabs a))) -0.3333333333333333))
(if (<= t_1 1e+103)
(cbrt (/ (/ 1.0 (fabs a)) t_0))
(exp
(*
(- (log (+ (fabs a) (fabs a))) (log (fabs g)))
-0.3333333333333333))))))))double code(double g, double a) {
double t_0 = 2.0 / fabs(g);
double t_1 = cbrt((fabs(g) / (2.0 * fabs(a))));
double tmp;
if (t_1 <= 4e-106) {
tmp = exp(((log(t_0) + log(fabs(a))) * -0.3333333333333333));
} else if (t_1 <= 1e+103) {
tmp = cbrt(((1.0 / fabs(a)) / t_0));
} else {
tmp = exp(((log((fabs(a) + fabs(a))) - log(fabs(g))) * -0.3333333333333333));
}
return copysign(1.0, g) * (copysign(1.0, a) * tmp);
}
public static double code(double g, double a) {
double t_0 = 2.0 / Math.abs(g);
double t_1 = Math.cbrt((Math.abs(g) / (2.0 * Math.abs(a))));
double tmp;
if (t_1 <= 4e-106) {
tmp = Math.exp(((Math.log(t_0) + Math.log(Math.abs(a))) * -0.3333333333333333));
} else if (t_1 <= 1e+103) {
tmp = Math.cbrt(((1.0 / Math.abs(a)) / t_0));
} else {
tmp = Math.exp(((Math.log((Math.abs(a) + Math.abs(a))) - Math.log(Math.abs(g))) * -0.3333333333333333));
}
return Math.copySign(1.0, g) * (Math.copySign(1.0, a) * tmp);
}
function code(g, a) t_0 = Float64(2.0 / abs(g)) t_1 = cbrt(Float64(abs(g) / Float64(2.0 * abs(a)))) tmp = 0.0 if (t_1 <= 4e-106) tmp = exp(Float64(Float64(log(t_0) + log(abs(a))) * -0.3333333333333333)); elseif (t_1 <= 1e+103) tmp = cbrt(Float64(Float64(1.0 / abs(a)) / t_0)); else tmp = exp(Float64(Float64(log(Float64(abs(a) + abs(a))) - log(abs(g))) * -0.3333333333333333)); end return Float64(copysign(1.0, g) * Float64(copysign(1.0, a) * tmp)) end
code[g_, a_] := Block[{t$95$0 = N[(2.0 / N[Abs[g], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[Abs[g], $MachinePrecision] / N[(2.0 * N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 4e-106], N[Exp[N[(N[(N[Log[t$95$0], $MachinePrecision] + N[Log[N[Abs[a], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 1e+103], N[Power[N[(N[(1.0 / N[Abs[a], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], 1/3], $MachinePrecision], N[Exp[N[(N[(N[Log[N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Log[N[Abs[g], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]], $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{2}{\left|g\right|}\\
t_1 := \sqrt[3]{\frac{\left|g\right|}{2 \cdot \left|a\right|}}\\
\mathsf{copysign}\left(1, g\right) \cdot \left(\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{-106}:\\
\;\;\;\;e^{\left(\log t\_0 + \log \left(\left|a\right|\right)\right) \cdot -0.3333333333333333}\\
\mathbf{elif}\;t\_1 \leq 10^{+103}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{1}{\left|a\right|}}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\log \left(\left|a\right| + \left|a\right|\right) - \log \left(\left|g\right|\right)\right) \cdot -0.3333333333333333}\\
\end{array}\right)
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 3.99999999999999976e-106Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
cbrt-prodN/A
metadata-evalN/A
cbrt-undivN/A
metadata-evalN/A
lift-cbrt.f64N/A
associate-*l/N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
lift-cbrt.f64N/A
mult-flipN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
div-flip-revN/A
lift-/.f64N/A
inv-powN/A
cbrt-powN/A
metadata-evalN/A
metadata-evalN/A
pow-to-expN/A
lower-unsound-exp.f64N/A
Applied rewrites35.8%
lift-log.f64N/A
lift-/.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l/N/A
lift-/.f64N/A
log-prodN/A
lower-unsound-+.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.8
Applied rewrites22.8%
if 3.99999999999999976e-106 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1e103Initial program 75.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6475.7
Applied rewrites75.7%
lift-/.f64N/A
div-flip-revN/A
lift-+.f64N/A
count-2N/A
associate-*l/N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6475.7
Applied rewrites75.7%
if 1e103 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
cbrt-prodN/A
metadata-evalN/A
cbrt-undivN/A
metadata-evalN/A
lift-cbrt.f64N/A
associate-*l/N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
lift-cbrt.f64N/A
mult-flipN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
div-flip-revN/A
lift-/.f64N/A
inv-powN/A
cbrt-powN/A
metadata-evalN/A
metadata-evalN/A
pow-to-expN/A
lower-unsound-exp.f64N/A
Applied rewrites35.8%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.8
Applied rewrites22.8%
(FPCore (g a)
:precision binary64
(let* ((t_0
(exp
(*
(- (log (+ (fabs a) (fabs a))) (log (fabs g)))
-0.3333333333333333)))
(t_1 (cbrt (/ (fabs g) (* 2.0 (fabs a))))))
(*
(copysign 1.0 g)
(*
(copysign 1.0 a)
(if (<= t_1 4e-106)
t_0
(if (<= t_1 1e+103)
(cbrt (/ (/ 1.0 (fabs a)) (/ 2.0 (fabs g))))
t_0))))))double code(double g, double a) {
double t_0 = exp(((log((fabs(a) + fabs(a))) - log(fabs(g))) * -0.3333333333333333));
double t_1 = cbrt((fabs(g) / (2.0 * fabs(a))));
double tmp;
if (t_1 <= 4e-106) {
tmp = t_0;
} else if (t_1 <= 1e+103) {
tmp = cbrt(((1.0 / fabs(a)) / (2.0 / fabs(g))));
} else {
tmp = t_0;
}
return copysign(1.0, g) * (copysign(1.0, a) * tmp);
}
public static double code(double g, double a) {
double t_0 = Math.exp(((Math.log((Math.abs(a) + Math.abs(a))) - Math.log(Math.abs(g))) * -0.3333333333333333));
double t_1 = Math.cbrt((Math.abs(g) / (2.0 * Math.abs(a))));
double tmp;
if (t_1 <= 4e-106) {
tmp = t_0;
} else if (t_1 <= 1e+103) {
tmp = Math.cbrt(((1.0 / Math.abs(a)) / (2.0 / Math.abs(g))));
} else {
tmp = t_0;
}
return Math.copySign(1.0, g) * (Math.copySign(1.0, a) * tmp);
}
function code(g, a) t_0 = exp(Float64(Float64(log(Float64(abs(a) + abs(a))) - log(abs(g))) * -0.3333333333333333)) t_1 = cbrt(Float64(abs(g) / Float64(2.0 * abs(a)))) tmp = 0.0 if (t_1 <= 4e-106) tmp = t_0; elseif (t_1 <= 1e+103) tmp = cbrt(Float64(Float64(1.0 / abs(a)) / Float64(2.0 / abs(g)))); else tmp = t_0; end return Float64(copysign(1.0, g) * Float64(copysign(1.0, a) * tmp)) end
code[g_, a_] := Block[{t$95$0 = N[Exp[N[(N[(N[Log[N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Log[N[Abs[g], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[Abs[g], $MachinePrecision] / N[(2.0 * N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 4e-106], t$95$0, If[LessEqual[t$95$1, 1e+103], N[Power[N[(N[(1.0 / N[Abs[a], $MachinePrecision]), $MachinePrecision] / N[(2.0 / N[Abs[g], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$0]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := e^{\left(\log \left(\left|a\right| + \left|a\right|\right) - \log \left(\left|g\right|\right)\right) \cdot -0.3333333333333333}\\
t_1 := \sqrt[3]{\frac{\left|g\right|}{2 \cdot \left|a\right|}}\\
\mathsf{copysign}\left(1, g\right) \cdot \left(\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{-106}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+103}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{1}{\left|a\right|}}{\frac{2}{\left|g\right|}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\right)
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 3.99999999999999976e-106 or 1e103 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
cbrt-prodN/A
metadata-evalN/A
cbrt-undivN/A
metadata-evalN/A
lift-cbrt.f64N/A
associate-*l/N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
lift-cbrt.f64N/A
mult-flipN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
div-flip-revN/A
lift-/.f64N/A
inv-powN/A
cbrt-powN/A
metadata-evalN/A
metadata-evalN/A
pow-to-expN/A
lower-unsound-exp.f64N/A
Applied rewrites35.8%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.8
Applied rewrites22.8%
if 3.99999999999999976e-106 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1e103Initial program 75.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6475.7
Applied rewrites75.7%
lift-/.f64N/A
div-flip-revN/A
lift-+.f64N/A
count-2N/A
associate-*l/N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6475.7
Applied rewrites75.7%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (+ a a) g))))
double code(double g, double a) {
return 1.0 / cbrt(((a + a) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((a + a) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(a + a) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt[3]{\frac{a + a}{g}}}
Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
cbrt-prodN/A
metadata-evalN/A
cbrt-undivN/A
metadata-evalN/A
lift-cbrt.f64N/A
associate-*l/N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
lift-cbrt.f64N/A
mult-flipN/A
div-flip-revN/A
metadata-evalN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-cbrt.f6475.0
Applied rewrites75.7%
(FPCore (g a) :precision binary64 (cbrt (* (/ 0.5 a) g)))
double code(double g, double a) {
return cbrt(((0.5 / a) * g));
}
public static double code(double g, double a) {
return Math.cbrt(((0.5 / a) * g));
}
function code(g, a) return cbrt(Float64(Float64(0.5 / a) * g)) end
code[g_, a_] := N[Power[N[(N[(0.5 / a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\sqrt[3]{\frac{0.5}{a} \cdot g}
Initial program 75.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval75.7
Applied rewrites75.7%
(FPCore (g a) :precision binary64 (cbrt (/ g (+ a a))))
double code(double g, double a) {
return cbrt((g / (a + a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (a + a)));
}
function code(g, a) return cbrt(Float64(g / Float64(a + a))) end
code[g_, a_] := N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\sqrt[3]{\frac{g}{a + a}}
Initial program 75.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6475.7
Applied rewrites75.7%
herbie shell --seed 2025171
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))