
(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 10 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 (/ 1.0 (/ (cbrt (* 2.0 a)) (cbrt g))))
double code(double g, double a) {
return 1.0 / (cbrt((2.0 * a)) / cbrt(g));
}
public static double code(double g, double a) {
return 1.0 / (Math.cbrt((2.0 * a)) / Math.cbrt(g));
}
function code(g, a) return Float64(1.0 / Float64(cbrt(Float64(2.0 * a)) / cbrt(g))) end
code[g_, a_] := N[(1.0 / N[(N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\sqrt[3]{2 \cdot a}}{\sqrt[3]{g}}}
\end{array}
Initial program 73.6%
cbrt-div98.7%
clear-num98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (* (cbrt g) (/ 1.0 (cbrt (* 2.0 a)))))
double code(double g, double a) {
return cbrt(g) * (1.0 / cbrt((2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt(g) * (1.0 / Math.cbrt((2.0 * a)));
}
function code(g, a) return Float64(cbrt(g) * Float64(1.0 / cbrt(Float64(2.0 * a)))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[(1.0 / N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{2 \cdot a}}
\end{array}
Initial program 73.6%
cbrt-div98.7%
div-inv98.7%
Applied egg-rr98.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 73.6%
div-inv73.6%
cbrt-prod98.7%
associate-/r*98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* 2.0 a))))
double code(double g, double a) {
return cbrt(g) / cbrt((2.0 * a));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((2.0 * a));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(2.0 * a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{2 \cdot a}}
\end{array}
Initial program 73.6%
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 (/ 1.0 (cbrt (* a (/ 2.0 g)))))
double code(double g, double a) {
return 1.0 / cbrt((a * (2.0 / g)));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt((a * (2.0 / g)));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(a * Float64(2.0 / g)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(a * N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{a \cdot \frac{2}{g}}}
\end{array}
Initial program 73.6%
clear-num72.9%
cbrt-div74.0%
metadata-eval74.0%
*-un-lft-identity74.0%
times-frac74.0%
metadata-eval74.0%
Applied egg-rr74.0%
associate-*r/74.0%
associate-*l/74.0%
Simplified74.0%
Final simplification74.0%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ a (/ g 2.0)))))
double code(double g, double a) {
return 1.0 / cbrt((a / (g / 2.0)));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt((a / (g / 2.0)));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(a / Float64(g / 2.0)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(a / N[(g / 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{a}{\frac{g}{2}}}}
\end{array}
Initial program 73.6%
cbrt-div98.7%
clear-num98.7%
Applied egg-rr98.7%
cbrt-undiv74.0%
*-commutative74.0%
associate-/l*74.0%
Applied egg-rr74.0%
Final simplification74.0%
(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 73.6%
expm1-log1p-u56.9%
expm1-udef22.5%
log1p-udef22.5%
add-exp-log39.3%
*-un-lft-identity39.3%
times-frac39.3%
metadata-eval39.3%
Applied egg-rr39.3%
+-commutative39.3%
associate--l+73.6%
metadata-eval73.6%
+-rgt-identity73.6%
associate-*r/73.6%
associate-*l/73.6%
Simplified73.6%
Final simplification73.6%
(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 73.6%
expm1-log1p-u56.9%
expm1-udef22.5%
log1p-udef22.5%
add-exp-log39.3%
*-un-lft-identity39.3%
times-frac39.3%
metadata-eval39.3%
Applied egg-rr39.3%
+-commutative39.3%
associate--l+73.6%
metadata-eval73.6%
+-rgt-identity73.6%
associate-*r/73.6%
associate-*l/73.6%
Simplified73.6%
associate-*l/73.6%
associate-/l*72.9%
Applied egg-rr72.9%
Taylor expanded in a around 0 73.6%
Simplified16.9%
Final simplification16.9%
(FPCore (g a) :precision binary64 (/ (/ (- g) a) -2.0))
double code(double g, double a) {
return (-g / a) / -2.0;
}
real(8) function code(g, a)
real(8), intent (in) :: g
real(8), intent (in) :: a
code = (-g / a) / (-2.0d0)
end function
public static double code(double g, double a) {
return (-g / a) / -2.0;
}
def code(g, a): return (-g / a) / -2.0
function code(g, a) return Float64(Float64(Float64(-g) / a) / -2.0) end
function tmp = code(g, a) tmp = (-g / a) / -2.0; end
code[g_, a_] := N[(N[((-g) / a), $MachinePrecision] / -2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-g}{a}}{-2}
\end{array}
Initial program 73.6%
clear-num72.9%
cbrt-div74.0%
metadata-eval74.0%
*-un-lft-identity74.0%
times-frac74.0%
metadata-eval74.0%
Applied egg-rr74.0%
associate-*r/74.0%
associate-/l*72.8%
Simplified72.8%
associate-/l*74.0%
cbrt-undiv98.7%
/-rgt-identity98.7%
div-inv98.7%
*-commutative98.7%
associate-/l*98.7%
add-log-exp4.8%
exp-lft-sqr4.8%
log-prod4.8%
add-log-exp14.3%
add-log-exp98.7%
Applied egg-rr98.7%
remove-double-div98.7%
clear-num98.7%
count-298.7%
cbrt-prod98.2%
associate-/l/98.1%
cbrt-div73.1%
frac-2neg73.1%
distribute-frac-neg73.1%
Applied egg-rr73.1%
Simplified6.0%
Final simplification6.0%
(FPCore (g a) :precision binary64 (/ -2.0 a))
double code(double g, double a) {
return -2.0 / a;
}
real(8) function code(g, a)
real(8), intent (in) :: g
real(8), intent (in) :: a
code = (-2.0d0) / a
end function
public static double code(double g, double a) {
return -2.0 / a;
}
def code(g, a): return -2.0 / a
function code(g, a) return Float64(-2.0 / a) end
function tmp = code(g, a) tmp = -2.0 / a; end
code[g_, a_] := N[(-2.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{a}
\end{array}
Initial program 73.6%
expm1-log1p-u56.9%
expm1-udef22.5%
log1p-udef22.5%
add-exp-log39.3%
*-un-lft-identity39.3%
times-frac39.3%
metadata-eval39.3%
Applied egg-rr39.3%
+-commutative39.3%
associate--l+73.6%
metadata-eval73.6%
+-rgt-identity73.6%
associate-*r/73.6%
associate-*l/73.6%
Simplified73.6%
associate-*l/73.6%
associate-/l*72.9%
Applied egg-rr72.9%
clear-num72.9%
associate-/r/72.9%
clear-num73.6%
metadata-eval73.6%
div-inv73.6%
associate-/l/73.6%
count-273.6%
cbrt-undiv98.7%
clear-num98.7%
remove-double-div98.7%
remove-double-div98.7%
Applied egg-rr6.3%
Taylor expanded in a around 0 3.2%
Simplified4.0%
Final simplification4.0%
herbie shell --seed 2023261
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))