Average Error: 15.3 → 0.8
Time: 17.1s
Precision: binary64
Cost: 19780
\[\sqrt[3]{\frac{g}{2 \cdot a}} \]
\[\begin{array}{l} \mathbf{if}\;\sqrt[3]{g} \ne 0:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.5}{a}}}{\sqrt[3]{\frac{1}{g}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{g \cdot 0.5}{a}}\\ \end{array} \]
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
(FPCore (g a)
 :precision binary64
 (if (!= (cbrt g) 0.0)
   (/ (cbrt (/ 0.5 a)) (cbrt (/ 1.0 g)))
   (cbrt (/ (* g 0.5) a))))
double code(double g, double a) {
	return cbrt((g / (2.0 * a)));
}
double code(double g, double a) {
	double tmp;
	if (cbrt(g) != 0.0) {
		tmp = cbrt((0.5 / a)) / cbrt((1.0 / g));
	} else {
		tmp = cbrt(((g * 0.5) / a));
	}
	return tmp;
}
public static double code(double g, double a) {
	return Math.cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
	double tmp;
	if (Math.cbrt(g) != 0.0) {
		tmp = Math.cbrt((0.5 / a)) / Math.cbrt((1.0 / g));
	} else {
		tmp = Math.cbrt(((g * 0.5) / a));
	}
	return tmp;
}
function code(g, a)
	return cbrt(Float64(g / Float64(2.0 * a)))
end
function code(g, a)
	tmp = 0.0
	if (cbrt(g) != 0.0)
		tmp = Float64(cbrt(Float64(0.5 / a)) / cbrt(Float64(1.0 / g)));
	else
		tmp = cbrt(Float64(Float64(g * 0.5) / a));
	end
	return tmp
end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
code[g_, a_] := If[Unequal[N[Power[g, 1/3], $MachinePrecision], 0.0], N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(1.0 / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(g * 0.5), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]]
\sqrt[3]{\frac{g}{2 \cdot a}}
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{g} \ne 0:\\
\;\;\;\;\frac{\sqrt[3]{\frac{0.5}{a}}}{\sqrt[3]{\frac{1}{g}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g \cdot 0.5}{a}}\\


\end{array}

Error

Derivation

  1. Initial program 15.3

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied egg-rr15.8

    \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{a}}}{\sqrt[3]{2}}} \]
  3. Applied egg-rr0.9

    \[\leadsto \color{blue}{\sqrt[3]{g} \cdot \sqrt[3]{\frac{-1}{-2 \cdot a}}} \]
  4. Simplified15.3

    \[\leadsto \color{blue}{\sqrt[3]{g \cdot \frac{0.5}{a}}} \]
    Proof
  5. Applied egg-rr0.8

    \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;\sqrt[3]{g} \ne 0:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.5}{a}}}{\sqrt[3]{\frac{1}{g}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{g \cdot 0.5}{a}}\\ } \end{array}} \]

Alternatives

Alternative 1
Error0.8
Cost13120
\[\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g} \]
Alternative 2
Error0.8
Cost13120
\[\frac{\sqrt[3]{g \cdot 0.5}}{\sqrt[3]{a}} \]
Alternative 3
Error15.3
Cost6720
\[\sqrt[3]{g \cdot \frac{0.5}{a}} \]
Alternative 4
Error15.3
Cost6720
\[\sqrt[3]{\frac{g}{2 \cdot a}} \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (g a)
  :name "2-ancestry mixing, zero discriminant"
  :precision binary64
  (cbrt (/ g (* 2.0 a))))