2-ancestry mixing, zero discriminant

Percentage Accurate: 75.9% → 98.7%
Time: 3.9s
Alternatives: 6
Speedup: 1.0×

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}

Sampling outcomes in binary64 precision:

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 6 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.9% 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.5× speedup?

\[\begin{array}{l} \\ \sqrt[3]{g \cdot -0.5} \cdot \sqrt[3]{\frac{-1}{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}
Derivation
  1. Initial program 77.7%

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

    \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a}} \cdot \sqrt[3]{-0.5 \cdot g}} \]
  4. Final simplification98.8%

    \[\leadsto \sqrt[3]{g \cdot -0.5} \cdot \sqrt[3]{\frac{-1}{a}} \]
  5. Add Preprocessing

Alternative 2: 83.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot a \leq -2 \cdot 10^{-287}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{-0.5}{a}}{\frac{-1}{g}}}\\ \mathbf{else}:\\ \;\;\;\;{\left(2 \cdot a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{g}\\ \end{array} \end{array} \]
(FPCore (g a)
 :precision binary64
 (if (<= (* 2.0 a) -2e-287)
   (cbrt (/ (/ -0.5 a) (/ -1.0 g)))
   (* (pow (* 2.0 a) -0.3333333333333333) (cbrt g))))
double code(double g, double a) {
	double tmp;
	if ((2.0 * a) <= -2e-287) {
		tmp = cbrt(((-0.5 / a) / (-1.0 / g)));
	} else {
		tmp = pow((2.0 * a), -0.3333333333333333) * cbrt(g);
	}
	return tmp;
}
public static double code(double g, double a) {
	double tmp;
	if ((2.0 * a) <= -2e-287) {
		tmp = Math.cbrt(((-0.5 / a) / (-1.0 / g)));
	} else {
		tmp = Math.pow((2.0 * a), -0.3333333333333333) * Math.cbrt(g);
	}
	return tmp;
}
function code(g, a)
	tmp = 0.0
	if (Float64(2.0 * a) <= -2e-287)
		tmp = cbrt(Float64(Float64(-0.5 / a) / Float64(-1.0 / g)));
	else
		tmp = Float64((Float64(2.0 * a) ^ -0.3333333333333333) * cbrt(g));
	end
	return tmp
end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -2e-287], N[Power[N[(N[(-0.5 / a), $MachinePrecision] / N[(-1.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(2.0 * a), $MachinePrecision], -0.3333333333333333], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -2 \cdot 10^{-287}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{-0.5}{a}}{\frac{-1}{g}}}\\

\mathbf{else}:\\
\;\;\;\;{\left(2 \cdot a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{g}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 2 binary64) a) < -2.00000000000000004e-287

    1. Initial program 76.7%

      \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{2 \cdot a}}} \]
      2. frac-2negN/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\mathsf{neg}\left(g\right)}{\mathsf{neg}\left(2 \cdot a\right)}}} \]
      3. clear-numN/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{1}{\frac{\mathsf{neg}\left(2 \cdot a\right)}{\mathsf{neg}\left(g\right)}}}} \]
      4. div-invN/A

        \[\leadsto \sqrt[3]{\frac{1}{\color{blue}{\left(\mathsf{neg}\left(2 \cdot a\right)\right) \cdot \frac{1}{\mathsf{neg}\left(g\right)}}}} \]
      5. associate-/r*N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{1}{\mathsf{neg}\left(2 \cdot a\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}}} \]
      6. inv-powN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{-1}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      7. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\color{blue}{\left(\frac{-1}{2} + \frac{-1}{2}\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} + \frac{-1}{2}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\left(\mathsf{neg}\left(\color{blue}{\frac{1}{2}}\right)\right) + \frac{-1}{2}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) + \left(\mathsf{neg}\left(\color{blue}{\frac{1}{2}}\right)\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      12. pow-prod-upN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot {\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      13. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right) \cdot \left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      14. sqr-negN/A

        \[\leadsto \sqrt[3]{\frac{{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      15. remove-double-negN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\color{blue}{\left(2 \cdot a\right)} \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      16. remove-double-negN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\left(2 \cdot a\right) \cdot \color{blue}{\left(2 \cdot a\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      17. pow2N/A

        \[\leadsto \sqrt[3]{\frac{{\color{blue}{\left({\left(2 \cdot a\right)}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      18. pow-powN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(2 \cdot a\right)}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      19. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(2 \cdot a\right)}^{\left(2 \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{2}}\right)\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      20. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(2 \cdot a\right)}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      21. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(2 \cdot a\right)}^{\color{blue}{-1}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      22. inv-powN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{\frac{1}{2 \cdot a}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
    4. Applied rewrites76.7%

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

    if -2.00000000000000004e-287 < (*.f64 #s(literal 2 binary64) a)

    1. Initial program 78.5%

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}} \]
    5. Step-by-step derivation
      1. lift-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{\frac{\frac{1}{2}}{a}}} \cdot \sqrt[3]{g} \]
      2. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{1}{2}}{a}}} \cdot \sqrt[3]{g} \]
      3. clear-numN/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{1}{\frac{a}{\frac{1}{2}}}}} \cdot \sqrt[3]{g} \]
      4. cbrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{a}{\frac{1}{2}}}}} \cdot \sqrt[3]{g} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{\frac{1}{2}}}} \cdot \sqrt[3]{g} \]
      6. pow1/3N/A

        \[\leadsto \frac{1}{\color{blue}{{\left(\frac{a}{\frac{1}{2}}\right)}^{\frac{1}{3}}}} \cdot \sqrt[3]{g} \]
      7. pow-flipN/A

        \[\leadsto \color{blue}{{\left(\frac{a}{\frac{1}{2}}\right)}^{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}} \cdot \sqrt[3]{g} \]
      8. lower-pow.f64N/A

        \[\leadsto \color{blue}{{\left(\frac{a}{\frac{1}{2}}\right)}^{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}} \cdot \sqrt[3]{g} \]
      9. clear-numN/A

        \[\leadsto {\color{blue}{\left(\frac{1}{\frac{\frac{1}{2}}{a}}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \cdot \sqrt[3]{g} \]
      10. associate-/r/N/A

        \[\leadsto {\color{blue}{\left(\frac{1}{\frac{1}{2}} \cdot a\right)}}^{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \cdot \sqrt[3]{g} \]
      11. metadata-evalN/A

        \[\leadsto {\left(\color{blue}{2} \cdot a\right)}^{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \cdot \sqrt[3]{g} \]
      12. lower-*.f64N/A

        \[\leadsto {\color{blue}{\left(2 \cdot a\right)}}^{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \cdot \sqrt[3]{g} \]
      13. metadata-eval92.2

        \[\leadsto {\left(2 \cdot a\right)}^{\color{blue}{-0.3333333333333333}} \cdot \sqrt[3]{g} \]
    6. Applied rewrites92.2%

      \[\leadsto \color{blue}{{\left(2 \cdot a\right)}^{-0.3333333333333333}} \cdot \sqrt[3]{g} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 83.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot a \leq -2 \cdot 10^{-287}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{-0.5}{a}}{\frac{-1}{g}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{0.5 \cdot g} \cdot {a}^{-0.3333333333333333}\\ \end{array} \end{array} \]
(FPCore (g a)
 :precision binary64
 (if (<= (* 2.0 a) -2e-287)
   (cbrt (/ (/ -0.5 a) (/ -1.0 g)))
   (* (cbrt (* 0.5 g)) (pow a -0.3333333333333333))))
double code(double g, double a) {
	double tmp;
	if ((2.0 * a) <= -2e-287) {
		tmp = cbrt(((-0.5 / a) / (-1.0 / g)));
	} else {
		tmp = cbrt((0.5 * g)) * pow(a, -0.3333333333333333);
	}
	return tmp;
}
public static double code(double g, double a) {
	double tmp;
	if ((2.0 * a) <= -2e-287) {
		tmp = Math.cbrt(((-0.5 / a) / (-1.0 / g)));
	} else {
		tmp = Math.cbrt((0.5 * g)) * Math.pow(a, -0.3333333333333333);
	}
	return tmp;
}
function code(g, a)
	tmp = 0.0
	if (Float64(2.0 * a) <= -2e-287)
		tmp = cbrt(Float64(Float64(-0.5 / a) / Float64(-1.0 / g)));
	else
		tmp = Float64(cbrt(Float64(0.5 * g)) * (a ^ -0.3333333333333333));
	end
	return tmp
end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -2e-287], N[Power[N[(N[(-0.5 / a), $MachinePrecision] / N[(-1.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -2 \cdot 10^{-287}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{-0.5}{a}}{\frac{-1}{g}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{0.5 \cdot g} \cdot {a}^{-0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 2 binary64) a) < -2.00000000000000004e-287

    1. Initial program 76.7%

      \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{2 \cdot a}}} \]
      2. frac-2negN/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\mathsf{neg}\left(g\right)}{\mathsf{neg}\left(2 \cdot a\right)}}} \]
      3. clear-numN/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{1}{\frac{\mathsf{neg}\left(2 \cdot a\right)}{\mathsf{neg}\left(g\right)}}}} \]
      4. div-invN/A

        \[\leadsto \sqrt[3]{\frac{1}{\color{blue}{\left(\mathsf{neg}\left(2 \cdot a\right)\right) \cdot \frac{1}{\mathsf{neg}\left(g\right)}}}} \]
      5. associate-/r*N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{1}{\mathsf{neg}\left(2 \cdot a\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}}} \]
      6. inv-powN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{-1}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      7. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\color{blue}{\left(\frac{-1}{2} + \frac{-1}{2}\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} + \frac{-1}{2}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\left(\mathsf{neg}\left(\color{blue}{\frac{1}{2}}\right)\right) + \frac{-1}{2}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) + \left(\mathsf{neg}\left(\color{blue}{\frac{1}{2}}\right)\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      12. pow-prod-upN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot {\left(\mathsf{neg}\left(2 \cdot a\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      13. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right) \cdot \left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      14. sqr-negN/A

        \[\leadsto \sqrt[3]{\frac{{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      15. remove-double-negN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\color{blue}{\left(2 \cdot a\right)} \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(2 \cdot a\right)\right)\right)\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      16. remove-double-negN/A

        \[\leadsto \sqrt[3]{\frac{{\left(\left(2 \cdot a\right) \cdot \color{blue}{\left(2 \cdot a\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      17. pow2N/A

        \[\leadsto \sqrt[3]{\frac{{\color{blue}{\left({\left(2 \cdot a\right)}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      18. pow-powN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{{\left(2 \cdot a\right)}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      19. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(2 \cdot a\right)}^{\left(2 \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{2}}\right)\right)\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      20. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(2 \cdot a\right)}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      21. metadata-evalN/A

        \[\leadsto \sqrt[3]{\frac{{\left(2 \cdot a\right)}^{\color{blue}{-1}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
      22. inv-powN/A

        \[\leadsto \sqrt[3]{\frac{\color{blue}{\frac{1}{2 \cdot a}}}{\frac{1}{\mathsf{neg}\left(g\right)}}} \]
    4. Applied rewrites76.7%

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

    if -2.00000000000000004e-287 < (*.f64 #s(literal 2 binary64) a)

    1. Initial program 78.5%

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a}} \cdot \sqrt[3]{-0.5 \cdot g}} \]
    4. Step-by-step derivation
      1. lift-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a}}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      2. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{-1}{a}}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      3. cbrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt[3]{-1}}{\sqrt[3]{a}}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      4. pow1/3N/A

        \[\leadsto \frac{\color{blue}{{-1}^{\frac{1}{3}}}}{\sqrt[3]{a}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      5. sqr-powN/A

        \[\leadsto \frac{\color{blue}{{-1}^{\left(\frac{\frac{1}{3}}{2}\right)} \cdot {-1}^{\left(\frac{\frac{1}{3}}{2}\right)}}}{\sqrt[3]{a}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\color{blue}{{\left(-1 \cdot -1\right)}^{\left(\frac{\frac{1}{3}}{2}\right)}}}{\sqrt[3]{a}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      7. metadata-evalN/A

        \[\leadsto \frac{{\color{blue}{1}}^{\left(\frac{\frac{1}{3}}{2}\right)}}{\sqrt[3]{a}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      8. pow-base-1N/A

        \[\leadsto \frac{\color{blue}{1}}{\sqrt[3]{a}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      9. inv-powN/A

        \[\leadsto \color{blue}{{\left(\sqrt[3]{a}\right)}^{-1}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      10. lower-pow.f64N/A

        \[\leadsto \color{blue}{{\left(\sqrt[3]{a}\right)}^{-1}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
      11. lower-cbrt.f641.7

        \[\leadsto {\color{blue}{\left(\sqrt[3]{a}\right)}}^{-1} \cdot \sqrt[3]{-0.5 \cdot g} \]
      12. lift-*.f64N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\color{blue}{\frac{-1}{2} \cdot g}} \]
      13. metadata-evalN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\color{blue}{\left(\frac{1}{2} \cdot -1\right)} \cdot g} \]
      14. associate-*r*N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\color{blue}{\frac{1}{2} \cdot \left(-1 \cdot g\right)}} \]
      15. neg-mul-1N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \color{blue}{\left(\mathsf{neg}\left(g\right)\right)}} \]
      16. lift-neg.f64N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \color{blue}{\left(-g\right)}} \]
      17. remove-double-divN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \color{blue}{\frac{1}{\frac{1}{-g}}}} \]
      18. metadata-evalN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \frac{1}{\frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{-g}}} \]
      19. lift-neg.f64N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \frac{1}{\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{\mathsf{neg}\left(g\right)}}}} \]
      20. frac-2negN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \frac{1}{\color{blue}{\frac{-1}{g}}}} \]
      21. lift-/.f64N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot \frac{1}{\color{blue}{\frac{-1}{g}}}} \]
      22. un-div-invN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\color{blue}{\frac{\frac{1}{2}}{\frac{-1}{g}}}} \]
      23. metadata-evalN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\color{blue}{\frac{\frac{-1}{2}}{-1}}}{\frac{-1}{g}}} \]
      24. lift-/.f64N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\color{blue}{\frac{-1}{g}}}} \]
      25. frac-2negN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\color{blue}{\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(g\right)}}}} \]
      26. lift-neg.f64N/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{-g}}}} \]
      27. metadata-evalN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\frac{\color{blue}{1}}{-g}}} \]
      28. inv-powN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\color{blue}{{\left(-g\right)}^{-1}}}} \]
      29. metadata-evalN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{{\left(-g\right)}^{\color{blue}{\left(\frac{-1}{2} + \frac{-1}{2}\right)}}}} \]
      30. pow-prod-upN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\color{blue}{{\left(-g\right)}^{\frac{-1}{2}} \cdot {\left(-g\right)}^{\frac{-1}{2}}}}} \]
      31. pow-prod-downN/A

        \[\leadsto {\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{\frac{\frac{\frac{-1}{2}}{-1}}{\color{blue}{{\left(\left(-g\right) \cdot \left(-g\right)\right)}^{\frac{-1}{2}}}}} \]
    5. Applied rewrites98.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{a}\right)}^{-1} \cdot \sqrt[3]{0.5 \cdot g}} \]
    6. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \color{blue}{{\left(\sqrt[3]{a}\right)}^{-1}} \cdot \sqrt[3]{\frac{1}{2} \cdot g} \]
      2. lift-cbrt.f64N/A

        \[\leadsto {\color{blue}{\left(\sqrt[3]{a}\right)}}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot g} \]
      3. pow1/3N/A

        \[\leadsto {\color{blue}{\left({a}^{\frac{1}{3}}\right)}}^{-1} \cdot \sqrt[3]{\frac{1}{2} \cdot g} \]
      4. pow-powN/A

        \[\leadsto \color{blue}{{a}^{\left(\frac{1}{3} \cdot -1\right)}} \cdot \sqrt[3]{\frac{1}{2} \cdot g} \]
      5. lower-pow.f64N/A

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

        \[\leadsto {a}^{\color{blue}{-0.3333333333333333}} \cdot \sqrt[3]{0.5 \cdot g} \]
    7. Applied rewrites92.2%

      \[\leadsto \color{blue}{{a}^{-0.3333333333333333}} \cdot \sqrt[3]{0.5 \cdot g} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;2 \cdot a \leq -2 \cdot 10^{-287}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{-0.5}{a}}{\frac{-1}{g}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{0.5 \cdot g} \cdot {a}^{-0.3333333333333333}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \sqrt[3]{g} \cdot \sqrt[3]{\frac{0.5}{a}} \end{array} \]
(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}
Derivation
  1. Initial program 77.7%

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

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

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}} \]
  5. Final simplification98.6%

    \[\leadsto \sqrt[3]{g} \cdot \sqrt[3]{\frac{0.5}{a}} \]
  6. Add Preprocessing

Alternative 5: 75.9% 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}
Derivation
  1. Initial program 77.7%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 6: 75.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\frac{0.5}{a} \cdot g} \end{array} \]
(FPCore (g a) :precision binary64 (cbrt (* (/ 0.5 a) g)))
double code(double g, double a) {
	return cbrt(((0.5 / a) * g));
}
public static double code(double g, double a) {
	return Math.cbrt(((0.5 / a) * g));
}
function code(g, a)
	return cbrt(Float64(Float64(0.5 / a) * g))
end
code[g_, a_] := N[Power[N[(N[(0.5 / a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}

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

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

    \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a}} \cdot \sqrt[3]{-0.5 \cdot g}} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g}} \]
    2. lift-cbrt.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a}}} \cdot \sqrt[3]{\frac{-1}{2} \cdot g} \]
    3. lift-cbrt.f64N/A

      \[\leadsto \sqrt[3]{\frac{-1}{a}} \cdot \color{blue}{\sqrt[3]{\frac{-1}{2} \cdot g}} \]
    4. cbrt-prodN/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{-1}{a} \cdot \left(\frac{-1}{2} \cdot g\right)}} \]
    5. lift-/.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{-1}{a}} \cdot \left(\frac{-1}{2} \cdot g\right)} \]
    6. associate-*l/N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{-1 \cdot \left(\frac{-1}{2} \cdot g\right)}{a}}} \]
    7. neg-mul-1N/A

      \[\leadsto \sqrt[3]{\frac{\color{blue}{\mathsf{neg}\left(\frac{-1}{2} \cdot g\right)}}{a}} \]
    8. lift-*.f64N/A

      \[\leadsto \sqrt[3]{\frac{\mathsf{neg}\left(\color{blue}{\frac{-1}{2} \cdot g}\right)}{a}} \]
    9. distribute-rgt-neg-outN/A

      \[\leadsto \sqrt[3]{\frac{\color{blue}{\frac{-1}{2} \cdot \left(\mathsf{neg}\left(g\right)\right)}}{a}} \]
    10. lift-neg.f64N/A

      \[\leadsto \sqrt[3]{\frac{\frac{-1}{2} \cdot \color{blue}{\left(-g\right)}}{a}} \]
    11. associate-*l/N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{-1}{2}}{a} \cdot \left(-g\right)}} \]
    12. lift-/.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{-1}{2}}{a}} \cdot \left(-g\right)} \]
    13. lift-*.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{-1}{2}}{a} \cdot \left(-g\right)}} \]
    14. lift-cbrt.f6477.7

      \[\leadsto \color{blue}{\sqrt[3]{\frac{-0.5}{a} \cdot \left(-g\right)}} \]
    15. lift-*.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{-1}{2}}{a} \cdot \left(-g\right)}} \]
    16. lift-/.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{-1}{2}}{a}} \cdot \left(-g\right)} \]
    17. associate-*l/N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{-1}{2} \cdot \left(-g\right)}{a}}} \]
    18. div-invN/A

      \[\leadsto \sqrt[3]{\color{blue}{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \frac{1}{a}}} \]
    19. inv-powN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \color{blue}{{a}^{-1}}} \]
    20. metadata-evalN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot {a}^{\color{blue}{\left(\frac{-1}{2} + \frac{-1}{2}\right)}}} \]
    21. pow-prod-upN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \color{blue}{\left({a}^{\frac{-1}{2}} \cdot {a}^{\frac{-1}{2}}\right)}} \]
    22. pow-prod-downN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \color{blue}{{\left(a \cdot a\right)}^{\frac{-1}{2}}}} \]
    23. sqr-negN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot {\color{blue}{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}}^{\frac{-1}{2}}} \]
    24. pow-prod-downN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{2}}\right)}} \]
    25. pow-prod-upN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{-1}{2} + \frac{-1}{2}\right)}}} \]
    26. metadata-evalN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\color{blue}{-1}}} \]
    27. inv-powN/A

      \[\leadsto \sqrt[3]{\left(\frac{-1}{2} \cdot \left(-g\right)\right) \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(a\right)}}} \]
  5. Applied rewrites77.7%

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

Reproduce

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