
(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 11 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 -0.5)) (cbrt (/ -1.0 a))))
double code(double g, double a) {
return cbrt((g * -0.5)) * cbrt((-1.0 / a));
}
public static double code(double g, double a) {
return Math.cbrt((g * -0.5)) * Math.cbrt((-1.0 / a));
}
function code(g, a) return Float64(cbrt(Float64(g * -0.5)) * cbrt(Float64(-1.0 / a))) end
code[g_, a_] := N[(N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot -0.5} \cdot \sqrt[3]{\frac{-1}{a}}
\end{array}
Initial program 69.9%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
inv-powN/A
lower-pow.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
pow1/3N/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f6498.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -5e-305) (cbrt (/ (- g) (* (/ -1.0 (/ -1.0 a)) -2.0))) (* (pow a -0.3333333333333333) (cbrt (* 0.5 g)))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-305) {
tmp = cbrt((-g / ((-1.0 / (-1.0 / a)) * -2.0)));
} else {
tmp = pow(a, -0.3333333333333333) * cbrt((0.5 * g));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-305) {
tmp = Math.cbrt((-g / ((-1.0 / (-1.0 / a)) * -2.0)));
} else {
tmp = Math.pow(a, -0.3333333333333333) * Math.cbrt((0.5 * g));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= -5e-305) tmp = cbrt(Float64(Float64(-g) / Float64(Float64(-1.0 / Float64(-1.0 / a)) * -2.0))); else tmp = Float64((a ^ -0.3333333333333333) * cbrt(Float64(0.5 * g))); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -5e-305], N[Power[N[((-g) / N[(N[(-1.0 / N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[a, -0.3333333333333333], $MachinePrecision] * N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -5 \cdot 10^{-305}:\\
\;\;\;\;\sqrt[3]{\frac{-g}{\frac{-1}{\frac{-1}{a}} \cdot -2}}\\
\mathbf{else}:\\
\;\;\;\;{a}^{-0.3333333333333333} \cdot \sqrt[3]{0.5 \cdot g}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.99999999999999985e-305Initial program 68.5%
lift-*.f64N/A
count-2-revN/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
distribute-neg-fracN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
neg-sub0N/A
flip--N/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
distribute-neg-fracN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
sub-negN/A
neg-sub0N/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
Applied rewrites40.8%
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift--.f64N/A
sub0-negN/A
frac-2negN/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites41.8%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
mul-1-negN/A
div-invN/A
lift-/.f64N/A
lower-/.f6468.5
Applied rewrites68.5%
if -4.99999999999999985e-305 < (*.f64 #s(literal 2 binary64) a) Initial program 71.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
inv-powN/A
lower-pow.f6498.7
Applied rewrites98.7%
lift-cbrt.f64N/A
pow1/3N/A
lift-pow.f64N/A
pow-powN/A
lower-pow.f64N/A
metadata-eval92.0
Applied rewrites92.0%
Final simplification79.6%
(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 69.9%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
clear-numN/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 (* 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 69.9%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
inv-powN/A
lower-pow.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
pow1/3N/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f6498.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
pow1/3N/A
pow1/3N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
unpow-prod-downN/A
lift-/.f64N/A
times-fracN/A
neg-mul-1N/A
lift-neg.f64N/A
*-commutativeN/A
lift-*.f64N/A
pow1/3N/A
cbrt-divN/A
pow1/3N/A
Applied rewrites98.6%
(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]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
\end{array}
Initial program 69.9%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
inv-powN/A
lower-pow.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
pow1/3N/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f6498.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Applied rewrites98.6%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (* 2.0 a) g))))
double code(double g, double a) {
return 1.0 / cbrt(((2.0 * a) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((2.0 * a) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(2.0 * a) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(2.0 * a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{2 \cdot a}{g}}}
\end{array}
Initial program 69.9%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
inv-powN/A
lower-pow.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
pow1/3N/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f6498.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Applied rewrites70.3%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (* (/ 2.0 g) a))))
double code(double g, double a) {
return 1.0 / cbrt(((2.0 / g) * a));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((2.0 / g) * a));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(2.0 / g) * a))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(2.0 / g), $MachinePrecision] * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{2}{g} \cdot a}}
\end{array}
Initial program 69.9%
lift-cbrt.f64N/A
lift-/.f64N/A
frac-2negN/A
cbrt-divN/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
distribute-neg-fracN/A
metadata-evalN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-neg.f64N/A
lower-cbrt.f641.7
lift-*.f64N/A
count-2-revN/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
distribute-neg-fracN/A
+-inversesN/A
+-inversesN/A
Applied rewrites98.6%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f6470.3
Applied rewrites70.3%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
cbrt-prodN/A
frac-2negN/A
metadata-evalN/A
metadata-evalN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lift-*.f64N/A
cbrt-prodN/A
div-invN/A
cbrt-undivN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
lower-cbrt.f64N/A
lower-*.f6470.3
Applied rewrites70.3%
(FPCore (g a) :precision binary64 (cbrt (* (* g -0.5) (/ -1.0 a))))
double code(double g, double a) {
return cbrt(((g * -0.5) * (-1.0 / a)));
}
public static double code(double g, double a) {
return Math.cbrt(((g * -0.5) * (-1.0 / a)));
}
function code(g, a) return cbrt(Float64(Float64(g * -0.5) * Float64(-1.0 / a))) end
code[g_, a_] := N[Power[N[(N[(g * -0.5), $MachinePrecision] * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g \cdot -0.5\right) \cdot \frac{-1}{a}}
\end{array}
Initial program 69.9%
lift-/.f64N/A
frac-2negN/A
neg-mul-1N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
times-fracN/A
distribute-neg-frac2N/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval70.0
Applied rewrites70.0%
Final simplification70.0%
(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]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a + a}}
\end{array}
Initial program 69.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6469.9
Applied rewrites69.9%
(FPCore (g a) :precision binary64 (cbrt (* (* 2.0 a) g)))
double code(double g, double a) {
return cbrt(((2.0 * a) * g));
}
public static double code(double g, double a) {
return Math.cbrt(((2.0 * a) * g));
}
function code(g, a) return cbrt(Float64(Float64(2.0 * a) * g)) end
code[g_, a_] := N[Power[N[(N[(2.0 * a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(2 \cdot a\right) \cdot g}
\end{array}
Initial program 69.9%
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f6433.2
Applied rewrites1.2%
lift-pow.f64N/A
unpow1/3N/A
lower-cbrt.f641.7
lift-*.f64N/A
/-rgt-identityN/A
clear-numN/A
unpow-1N/A
metadata-evalN/A
pow-powN/A
pow2N/A
sqr-neg-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
inv-powN/A
clear-num-revN/A
metadata-evalN/A
frac-2negN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f645.7
Applied rewrites5.7%
(FPCore (g a) :precision binary64 (pow (* (+ a a) g) 0.3333333333333333))
double code(double g, double a) {
return pow(((a + a) * g), 0.3333333333333333);
}
real(8) function code(g, a)
real(8), intent (in) :: g
real(8), intent (in) :: a
code = ((a + a) * g) ** 0.3333333333333333d0
end function
public static double code(double g, double a) {
return Math.pow(((a + a) * g), 0.3333333333333333);
}
def code(g, a): return math.pow(((a + a) * g), 0.3333333333333333)
function code(g, a) return Float64(Float64(a + a) * g) ^ 0.3333333333333333 end
function tmp = code(g, a) tmp = ((a + a) * g) ^ 0.3333333333333333; end
code[g_, a_] := N[Power[N[(N[(a + a), $MachinePrecision] * g), $MachinePrecision], 0.3333333333333333], $MachinePrecision]
\begin{array}{l}
\\
{\left(\left(a + a\right) \cdot g\right)}^{0.3333333333333333}
\end{array}
Initial program 69.9%
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f6433.2
Applied rewrites1.2%
lift-*.f64N/A
/-rgt-identityN/A
clear-numN/A
unpow-1N/A
metadata-evalN/A
pow-powN/A
pow2N/A
sqr-neg-revN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
inv-powN/A
clear-num-revN/A
metadata-evalN/A
frac-2negN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
*-commutativeN/A
count-2-revN/A
lower-+.f643.2
Applied rewrites3.2%
herbie shell --seed 2024312
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))