
(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 8 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 g) (/ 1.0 (cbrt (* a 2.0)))))
double code(double g, double a) {
return cbrt(g) * (1.0 / cbrt((a * 2.0)));
}
public static double code(double g, double a) {
return Math.cbrt(g) * (1.0 / Math.cbrt((a * 2.0)));
}
function code(g, a) return Float64(cbrt(g) * Float64(1.0 / cbrt(Float64(a * 2.0)))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[(1.0 / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a \cdot 2}}
\end{array}
Initial program 75.5%
cbrt-div98.8%
div-inv98.8%
Applied egg-rr98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (* (cbrt g) (cbrt (/ 0.5 a))))
double code(double g, double a) {
return cbrt(g) * cbrt((0.5 / a));
}
public static double code(double g, double a) {
return Math.cbrt(g) * Math.cbrt((0.5 / a));
}
function code(g, a) return Float64(cbrt(g) * cbrt(Float64(0.5 / a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \sqrt[3]{\frac{0.5}{a}}
\end{array}
Initial program 75.5%
div-inv75.5%
cbrt-prod98.8%
associate-/r*98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* a 2.0))))
double code(double g, double a) {
return cbrt(g) / cbrt((a * 2.0));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a * 2.0));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a * 2.0))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a \cdot 2}}
\end{array}
Initial program 75.5%
cbrt-div98.8%
div-inv98.8%
Applied egg-rr98.8%
associate-*r/98.8%
*-rgt-identity98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.8%
(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 75.5%
expm1-log1p-u57.6%
expm1-udef24.0%
log1p-udef24.0%
add-exp-log41.9%
*-un-lft-identity41.9%
times-frac41.9%
metadata-eval41.9%
Applied egg-rr41.9%
+-commutative41.9%
associate--l+75.5%
metadata-eval75.5%
+-rgt-identity75.5%
associate-*r/75.5%
associate-*l/75.5%
Simplified75.5%
Final simplification75.5%
(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 75.5%
Final simplification75.5%
(FPCore (g a) :precision binary64 (cbrt (/ g a)))
double code(double g, double a) {
return cbrt((g / a));
}
public static double code(double g, double a) {
return Math.cbrt((g / a));
}
function code(g, a) return cbrt(Float64(g / a)) end
code[g_, a_] := N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 75.5%
cbrt-div98.8%
div-inv98.8%
Applied egg-rr98.8%
*-commutative98.8%
Simplified98.8%
clear-num98.8%
un-div-inv98.8%
/-rgt-identity98.8%
metadata-eval98.8%
div-inv98.8%
div-inv98.8%
metadata-eval98.8%
add-log-exp4.7%
exp-lft-sqr4.7%
log-prod4.7%
add-log-exp13.6%
add-log-exp98.8%
Applied egg-rr98.8%
flip-+0.0%
difference-of-squares0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
metadata-eval0.0%
associate-*r/0.0%
metadata-eval0.0%
+-inverses0.0%
difference-of-squares0.0%
+-inverses0.0%
metadata-eval0.0%
associate-*r/0.0%
metadata-eval0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
flip-+5.2%
associate-*l*5.2%
add-cbrt-cube6.1%
add-cube-cbrt6.1%
add-cube-cbrt6.1%
Applied egg-rr6.1%
Simplified21.2%
add-log-exp5.4%
*-un-lft-identity5.4%
log-prod5.4%
metadata-eval5.4%
add-log-exp21.2%
cbrt-undiv17.1%
Applied egg-rr17.1%
+-lft-identity17.1%
Simplified17.1%
Final simplification17.1%
(FPCore (g a) :precision binary64 (cbrt -2.0))
double code(double g, double a) {
return cbrt(-2.0);
}
public static double code(double g, double a) {
return Math.cbrt(-2.0);
}
function code(g, a) return cbrt(-2.0) end
code[g_, a_] := N[Power[-2.0, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-2}
\end{array}
Initial program 75.5%
expm1-log1p-u57.6%
expm1-udef24.0%
log1p-udef24.0%
add-exp-log41.9%
*-un-lft-identity41.9%
times-frac41.9%
metadata-eval41.9%
Applied egg-rr41.9%
+-commutative41.9%
associate--l+75.5%
metadata-eval75.5%
+-rgt-identity75.5%
associate-*r/75.5%
associate-*l/75.5%
Simplified75.5%
associate-*l/75.5%
associate-/l*74.4%
Applied egg-rr74.4%
Taylor expanded in a around 0 75.5%
Simplified4.8%
Final simplification4.8%
(FPCore (g a) :precision binary64 0.0)
double code(double g, double a) {
return 0.0;
}
real(8) function code(g, a)
real(8), intent (in) :: g
real(8), intent (in) :: a
code = 0.0d0
end function
public static double code(double g, double a) {
return 0.0;
}
def code(g, a): return 0.0
function code(g, a) return 0.0 end
function tmp = code(g, a) tmp = 0.0; end
code[g_, a_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 75.5%
expm1-log1p-u57.6%
expm1-udef24.0%
log1p-udef24.0%
add-exp-log41.9%
*-un-lft-identity41.9%
times-frac41.9%
metadata-eval41.9%
Applied egg-rr41.9%
Taylor expanded in g around 0 3.3%
Final simplification3.3%
herbie shell --seed 2023243
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))