2-ancestry mixing, zero discriminant

Percentage Accurate: 75.8% → 98.7%
Time: 7.2s
Alternatives: 8
Speedup: 0.6×

Specification

?
\[\begin{array}{l} \\ \sqrt[3]{\frac{g}{2 \cdot a}} \end{array} \]
(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}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 75.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\frac{g}{2 \cdot a}} \end{array} \]
(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}

Alternative 1: 98.7% accurate, 0.3× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ \begin{array}{l} t_0 := {\left(\frac{1}{a\_m}\right)}^{\left(\frac{-1}{2}\right)}\\ a\_s \cdot \frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{t\_0 \cdot t\_0}} \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m)
 :precision binary64
 (let* ((t_0 (pow (/ 1.0 a_m) (/ -1.0 2.0))))
   (* a_s (/ (cbrt (* 0.5 g)) (cbrt (* t_0 t_0))))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	double t_0 = pow((1.0 / a_m), (-1.0 / 2.0));
	return a_s * (cbrt((0.5 * g)) / cbrt((t_0 * t_0)));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	double t_0 = Math.pow((1.0 / a_m), (-1.0 / 2.0));
	return a_s * (Math.cbrt((0.5 * g)) / Math.cbrt((t_0 * t_0)));
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	t_0 = Float64(1.0 / a_m) ^ Float64(-1.0 / 2.0)
	return Float64(a_s * Float64(cbrt(Float64(0.5 * g)) / cbrt(Float64(t_0 * t_0))))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := Block[{t$95$0 = N[Power[N[(1.0 / a$95$m), $MachinePrecision], N[(-1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(a$95$s * N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(t$95$0 * t$95$0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
\begin{array}{l}
t_0 := {\left(\frac{1}{a\_m}\right)}^{\left(\frac{-1}{2}\right)}\\
a\_s \cdot \frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{t\_0 \cdot t\_0}}
\end{array}
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}} \]
  3. Taylor expanded in g around 0

    \[\leadsto \frac{\sqrt[3]{\color{blue}{\frac{1}{2} \cdot g}}}{\sqrt[3]{a}} \]
  4. Applied rewrites98.7%

    \[\leadsto \frac{\sqrt[3]{\color{blue}{0.5 \cdot g}}}{\sqrt[3]{a}} \]
  5. Applied rewrites98.7%

    \[\leadsto \frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{\color{blue}{{\left(\frac{1}{a}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{1}{a}\right)}^{\left(\frac{-1}{2}\right)}}}} \]
  6. Add Preprocessing

Alternative 2: 98.7% accurate, 0.6× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a\_m + a\_m}} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m)
 :precision binary64
 (* a_s (/ (cbrt g) (cbrt (+ a_m a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	return a_s * (cbrt(g) / cbrt((a_m + a_m)));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	return a_s * (Math.cbrt(g) / Math.cbrt((a_m + a_m)));
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	return Float64(a_s * Float64(cbrt(g) / cbrt(Float64(a_m + a_m))))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := N[(a$95$s * N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a$95$m + a$95$m), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a\_m + a\_m}}
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}} \]
  3. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}} \]
  4. Add Preprocessing

Alternative 3: 75.8% accurate, 0.3× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ \begin{array}{l} t_0 := \sqrt[3]{\frac{g}{2 \cdot a\_m}}\\ t_1 := \frac{\sqrt[3]{g}}{\sqrt[3]{a\_m}}\\ a\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+100}:\\ \;\;\;\;\sqrt[3]{\frac{g}{a\_m + a\_m}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m)
 :precision binary64
 (let* ((t_0 (cbrt (/ g (* 2.0 a_m)))) (t_1 (/ (cbrt g) (cbrt a_m))))
   (*
    a_s
    (if (<= t_0 0.0) t_1 (if (<= t_0 2e+100) (cbrt (/ g (+ a_m a_m))) t_1)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	double t_0 = cbrt((g / (2.0 * a_m)));
	double t_1 = cbrt(g) / cbrt(a_m);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = t_1;
	} else if (t_0 <= 2e+100) {
		tmp = cbrt((g / (a_m + a_m)));
	} else {
		tmp = t_1;
	}
	return a_s * tmp;
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	double t_0 = Math.cbrt((g / (2.0 * a_m)));
	double t_1 = Math.cbrt(g) / Math.cbrt(a_m);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = t_1;
	} else if (t_0 <= 2e+100) {
		tmp = Math.cbrt((g / (a_m + a_m)));
	} else {
		tmp = t_1;
	}
	return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	t_0 = cbrt(Float64(g / Float64(2.0 * a_m)))
	t_1 = Float64(cbrt(g) / cbrt(a_m))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = t_1;
	elseif (t_0 <= 2e+100)
		tmp = cbrt(Float64(g / Float64(a_m + a_m)));
	else
		tmp = t_1;
	end
	return Float64(a_s * tmp)
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a$95$m, 1/3], $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 2e+100], N[Power[N[(g / N[(a$95$m + a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$1]]), $MachinePrecision]]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a\_m}}\\
t_1 := \frac{\sqrt[3]{g}}{\sqrt[3]{a\_m}}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+100}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a\_m + a\_m}}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 0.0 or 2.00000000000000003e100 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a)))

    1. Initial program 75.8%

      \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
    2. Applied rewrites98.7%

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}} \]
    3. Applied rewrites98.7%

      \[\leadsto \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}} \]
    4. Applied rewrites21.2%

      \[\leadsto \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}} \]

    if 0.0 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 2.00000000000000003e100

    1. Initial program 75.8%

      \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
    2. Applied rewrites75.8%

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 49.9% accurate, 1.0× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \sqrt[3]{\frac{g}{a\_m + a\_m}} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m) :precision binary64 (* a_s (cbrt (/ g (+ a_m a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	return a_s * cbrt((g / (a_m + a_m)));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	return a_s * Math.cbrt((g / (a_m + a_m)));
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	return Float64(a_s * cbrt(Float64(g / Float64(a_m + a_m))))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := N[(a$95$s * N[Power[N[(g / N[(a$95$m + a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \sqrt[3]{\frac{g}{a\_m + a\_m}}
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites75.8%

    \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
  3. Add Preprocessing

Alternative 5: 17.2% accurate, 1.2× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \sqrt[3]{\frac{g}{a\_m}} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m) :precision binary64 (* a_s (cbrt (/ g a_m))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	return a_s * cbrt((g / a_m));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	return a_s * Math.cbrt((g / a_m));
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	return Float64(a_s * cbrt(Float64(g / a_m)))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := N[(a$95$s * N[Power[N[(g / a$95$m), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \sqrt[3]{\frac{g}{a\_m}}
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}} \]
  3. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}} \]
  4. Applied rewrites17.2%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
  5. Add Preprocessing

Alternative 6: 7.9% accurate, 1.2× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \frac{\sqrt[3]{g}}{1} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m) :precision binary64 (* a_s (/ (cbrt g) 1.0)))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	return a_s * (cbrt(g) / 1.0);
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	return a_s * (Math.cbrt(g) / 1.0);
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	return Float64(a_s * Float64(cbrt(g) / 1.0))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := N[(a$95$s * N[(N[Power[g, 1/3], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \frac{\sqrt[3]{g}}{1}
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}} \]
  3. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}} \]
  4. Taylor expanded in a around 0

    \[\leadsto \frac{\sqrt[3]{g}}{\color{blue}{\sqrt[3]{a} \cdot \sqrt[3]{2}}} \]
  5. Applied rewrites7.9%

    \[\leadsto \frac{\sqrt[3]{g}}{\color{blue}{1}} \]
  6. Add Preprocessing

Alternative 7: 1.6% accurate, 1.2× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \sqrt[3]{-0.5 \cdot g} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m) :precision binary64 (* a_s (cbrt (* -0.5 g))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	return a_s * cbrt((-0.5 * g));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	return a_s * Math.cbrt((-0.5 * g));
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	return Float64(a_s * cbrt(Float64(-0.5 * g)))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := N[(a$95$s * N[Power[N[(-0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \sqrt[3]{-0.5 \cdot g}
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites3.9%

    \[\leadsto \color{blue}{{\left(\frac{g}{2}\right)}^{0.3333333333333333}} \]
  3. Taylor expanded in g around 0

    \[\leadsto \color{blue}{\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{2}}} \]
  4. Applied rewrites1.6%

    \[\leadsto \color{blue}{\sqrt[3]{-0.5 \cdot g}} \]
  5. Add Preprocessing

Alternative 8: 1.6% accurate, 1.3× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \left(-\sqrt[3]{g}\right) \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m) :precision binary64 (* a_s (- (cbrt g))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
	return a_s * -cbrt(g);
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
	return a_s * -Math.cbrt(g);
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, g, a_m)
	return Float64(a_s * Float64(-cbrt(g)))
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g_, a$95$m_] := N[(a$95$s * (-N[Power[g, 1/3], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \left(-\sqrt[3]{g}\right)
\end{array}
Derivation
  1. Initial program 75.8%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Applied rewrites3.9%

    \[\leadsto \color{blue}{{\left(\frac{g}{2}\right)}^{0.3333333333333333}} \]
  3. Taylor expanded in g around -inf

    \[\leadsto \color{blue}{-1 \cdot \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{-1}{2}}\right)} \]
  4. Applied rewrites1.6%

    \[\leadsto \color{blue}{-\sqrt[3]{g}} \]
  5. Add Preprocessing

Reproduce

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