
(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 6 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) (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 76.2%
cbrt-div98.7%
div-inv98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.7%
(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 76.2%
div-inv76.2%
cbrt-prod98.6%
associate-/r*98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification98.6%
(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 76.2%
expm1-log1p-u58.2%
expm1-udef22.6%
log1p-udef22.6%
add-exp-log40.5%
*-un-lft-identity40.5%
times-frac40.5%
metadata-eval40.5%
Applied egg-rr40.5%
+-commutative40.5%
associate--l+76.2%
metadata-eval76.2%
+-rgt-identity76.2%
associate-*r/76.2%
associate-*l/76.2%
Simplified76.2%
Final simplification76.2%
(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 76.2%
Final simplification76.2%
(FPCore (g a) :precision binary64 (cbrt g))
double code(double g, double a) {
return cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt(g);
}
function code(g, a) return cbrt(g) end
code[g_, a_] := N[Power[g, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g}
\end{array}
Initial program 76.2%
clear-num74.3%
cbrt-div75.8%
metadata-eval75.8%
*-un-lft-identity75.8%
times-frac75.8%
metadata-eval75.8%
Applied egg-rr75.8%
associate-*r/75.8%
associate-*l/75.4%
Simplified75.4%
associate-*l/75.8%
*-commutative75.8%
cbrt-div98.7%
div-inv98.7%
metadata-eval98.7%
div-inv98.7%
add-log-exp4.6%
div-inv4.6%
metadata-eval4.6%
exp-lft-sqr4.6%
log-prod4.6%
add-log-exp14.0%
add-log-exp98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
associate-/r/98.7%
Applied egg-rr4.8%
Simplified5.0%
Final simplification5.0%
(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 76.2%
clear-num74.3%
cbrt-div75.8%
metadata-eval75.8%
*-un-lft-identity75.8%
times-frac75.8%
metadata-eval75.8%
Applied egg-rr75.8%
associate-*r/75.8%
associate-*l/75.4%
Simplified75.4%
associate-*l/75.8%
*-commutative75.8%
cbrt-div98.7%
div-inv98.7%
metadata-eval98.7%
div-inv98.7%
add-log-exp4.6%
div-inv4.6%
metadata-eval4.6%
exp-lft-sqr4.6%
log-prod4.6%
add-log-exp14.0%
add-log-exp98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
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%
metadata-eval0.0%
+-inverses0.0%
flip-+4.6%
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%
metadata-eval0.0%
+-inverses0.0%
flip-+5.5%
Applied egg-rr6.4%
clear-num6.4%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
metadata-eval0.0%
associate-/r/0.0%
metadata-eval0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Simplified3.3%
Final simplification3.3%
herbie shell --seed 2023182
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))