
(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]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 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]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
(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]
\begin{array}{l}
\\
\frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{a}}
\end{array}
Initial program 78.7%
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
inv-powN/A
pow-powN/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f6498.6%
Applied egg-rr98.6%
sqr-powN/A
pow2N/A
pow-lowering-pow.f64N/A
pow-lowering-pow.f64N/A
metadata-eval98.8%
Applied egg-rr98.8%
associate-/l*N/A
*-commutativeN/A
clear-numN/A
cbrt-divN/A
pow1/3N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
pow-prod-downN/A
metadata-evalN/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
clear-numN/A
pow1/3N/A
associate-/r/N/A
associate-*l/N/A
cbrt-divN/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f6498.8%
Applied egg-rr98.8%
(FPCore (g a)
:precision binary64
(let* ((t_0 (/ g (* a 2.0))))
(if (<= t_0 -1e-318)
(cbrt t_0)
(if (<= t_0 2e-319)
(/ g (cbrt (/ (* a (* g g)) 0.5)))
(/ 1.0 (cbrt (/ a (/ g 2.0))))))))
double code(double g, double a) {
double t_0 = g / (a * 2.0);
double tmp;
if (t_0 <= -1e-318) {
tmp = cbrt(t_0);
} else if (t_0 <= 2e-319) {
tmp = g / cbrt(((a * (g * g)) / 0.5));
} else {
tmp = 1.0 / cbrt((a / (g / 2.0)));
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = g / (a * 2.0);
double tmp;
if (t_0 <= -1e-318) {
tmp = Math.cbrt(t_0);
} else if (t_0 <= 2e-319) {
tmp = g / Math.cbrt(((a * (g * g)) / 0.5));
} else {
tmp = 1.0 / Math.cbrt((a / (g / 2.0)));
}
return tmp;
}
function code(g, a) t_0 = Float64(g / Float64(a * 2.0)) tmp = 0.0 if (t_0 <= -1e-318) tmp = cbrt(t_0); elseif (t_0 <= 2e-319) tmp = Float64(g / cbrt(Float64(Float64(a * Float64(g * g)) / 0.5))); else tmp = Float64(1.0 / cbrt(Float64(a / Float64(g / 2.0)))); end return tmp end
code[g_, a_] := Block[{t$95$0 = N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-318], N[Power[t$95$0, 1/3], $MachinePrecision], If[LessEqual[t$95$0, 2e-319], N[(g / N[Power[N[(N[(a * N[(g * g), $MachinePrecision]), $MachinePrecision] / 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(a / N[(g / 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{g}{a \cdot 2}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-318}:\\
\;\;\;\;\sqrt[3]{t\_0}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-319}:\\
\;\;\;\;\frac{g}{\sqrt[3]{\frac{a \cdot \left(g \cdot g\right)}{0.5}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{\frac{a}{\frac{g}{2}}}}\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -9.9999875e-319Initial program 88.5%
if -9.9999875e-319 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 1.99998e-319Initial program 7.8%
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
inv-powN/A
pow-powN/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f6498.6%
Applied egg-rr98.6%
sqr-powN/A
pow2N/A
pow-lowering-pow.f64N/A
pow-lowering-pow.f64N/A
metadata-eval98.1%
Applied egg-rr98.1%
associate-/l*N/A
*-commutativeN/A
clear-numN/A
cbrt-divN/A
pow1/3N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
pow-prod-downN/A
metadata-evalN/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
clear-numN/A
pow1/3N/A
associate-/r/N/A
associate-*l/N/A
cbrt-divN/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f6498.4%
Applied egg-rr98.4%
Applied egg-rr34.2%
if 1.99998e-319 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 87.8%
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
inv-powN/A
pow-powN/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f6498.6%
Applied egg-rr98.6%
*-commutativeN/A
associate-/l*N/A
div-invN/A
pow1/3N/A
pow-flipN/A
metadata-evalN/A
pow-prod-downN/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
clear-numN/A
pow1/3N/A
cbrt-prodN/A
*-commutativeN/A
associate-*l/N/A
clear-numN/A
metadata-evalN/A
cbrt-divN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr88.8%
Final simplification82.3%
(FPCore (g a) :precision binary64 (cbrt (/ g (* a 2.0))))
double code(double g, double a) {
return cbrt((g / (a * 2.0)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (a * 2.0)));
}
function code(g, a) return cbrt(Float64(g / Float64(a * 2.0))) end
code[g_, a_] := N[Power[N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a \cdot 2}}
\end{array}
Initial program 78.7%
Final simplification78.7%
(FPCore (g a) :precision binary64 (cbrt (* g (/ 0.5 a))))
double code(double g, double a) {
return cbrt((g * (0.5 / a)));
}
public static double code(double g, double a) {
return Math.cbrt((g * (0.5 / a)));
}
function code(g, a) return cbrt(Float64(g * Float64(0.5 / a))) end
code[g_, a_] := N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot \frac{0.5}{a}}
\end{array}
Initial program 78.7%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-eval78.7%
Applied egg-rr78.7%
Final simplification78.7%
herbie shell --seed 2024147
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))