2-ancestry mixing, zero discriminant

Percentage Accurate: 76.4% → 98.7%
Time: 8.7s
Alternatives: 5
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 5 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: 76.4% 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} \\ \frac{\sqrt[3]{g}}{\sqrt[3]{\frac{2}{\frac{1}{a}}}} \end{array} \]
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (/ 2.0 (/ 1.0 a)))))
double code(double g, double a) {
	return cbrt(g) / cbrt((2.0 / (1.0 / a)));
}
public static double code(double g, double a) {
	return Math.cbrt(g) / Math.cbrt((2.0 / (1.0 / a)));
}
function code(g, a)
	return Float64(cbrt(g) / cbrt(Float64(2.0 / Float64(1.0 / a))))
end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(2.0 / N[(1.0 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sqrt[3]{g}}{\sqrt[3]{\frac{2}{\frac{1}{a}}}}
\end{array}
Derivation
  1. Initial program 74.3%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/r*N/A

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left({\left(\mathsf{neg}\left(\frac{g}{2}\right)\right)}^{\frac{1}{3}}\right), \color{blue}{\left(\sqrt[3]{\frac{1}{\mathsf{neg}\left(a\right)}}\right)}\right) \]
    7. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(\mathsf{neg}\left(\frac{g}{2}\right)\right), \frac{1}{3}\right), \left(\sqrt[3]{\color{blue}{\frac{1}{\mathsf{neg}\left(a\right)}}}\right)\right) \]
    8. distribute-neg-frac2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(\frac{g}{\mathsf{neg}\left(2\right)}\right), \frac{1}{3}\right), \left(\sqrt[3]{\frac{\color{blue}{1}}{\mathsf{neg}\left(a\right)}}\right)\right) \]
    9. /-lowering-/.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \left(\sqrt[3]{\frac{1}{\mathsf{neg}\left(a\right)}}\right)\right) \]
    11. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\left(\frac{1}{\mathsf{neg}\left(a\right)}\right)\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(a\right)}\right)\right)\right) \]
    13. frac-2negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\left(\frac{-1}{a}\right)\right)\right) \]
    14. /-lowering-/.f6446.4%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(-1, a\right)\right)\right) \]
  4. Applied egg-rr46.4%

    \[\leadsto \color{blue}{{\left(\frac{g}{-2}\right)}^{0.3333333333333333} \cdot \sqrt[3]{\frac{-1}{a}}} \]
  5. Step-by-step derivation
    1. unpow1/3N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{g}{-2}}\right), \mathsf{cbrt.f64}\left(\color{blue}{\mathsf{/.f64}\left(-1, a\right)}\right)\right) \]
    2. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(\frac{g}{-2}\right)\right), \mathsf{cbrt.f64}\left(\color{blue}{\mathsf{/.f64}\left(-1, a\right)}\right)\right) \]
    3. /-lowering-/.f6498.8%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, -2\right)\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(\color{blue}{-1}, a\right)\right)\right) \]
  6. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{-2}}} \cdot \sqrt[3]{\frac{-1}{a}} \]
  7. Step-by-step derivation
    1. cbrt-unprodN/A

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

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

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

      \[\leadsto \sqrt[3]{\frac{\left(\mathsf{neg}\left(g\right)\right) \cdot -1}{2 \cdot a}} \]
    5. cbrt-divN/A

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

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

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

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

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

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

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

      \[\leadsto \frac{{g}^{\frac{1}{3}}}{\sqrt[3]{-2 \cdot \left(\mathsf{neg}\left(a\right)\right)}} \]
    13. *-commutativeN/A

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

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

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

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

      \[\leadsto \frac{{g}^{\frac{1}{3}}}{\sqrt[3]{\frac{a}{\frac{1}{2}}}} \]
    18. /-lowering-/.f64N/A

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

      \[\leadsto \mathsf{/.f64}\left(\left(\sqrt[3]{g}\right), \left(\sqrt[3]{\color{blue}{\frac{a}{\frac{1}{2}}}}\right)\right) \]
    20. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \left(\sqrt[3]{\color{blue}{\frac{a}{\frac{1}{2}}}}\right)\right) \]
    21. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\left(\frac{a}{\frac{1}{2}}\right)\right)\right) \]
    22. /-lowering-/.f6498.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(a, \frac{1}{2}\right)\right)\right) \]
  8. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{\frac{a}{0.5}}}} \]
  9. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\left(\frac{1}{\frac{\frac{1}{2}}{a}}\right)\right)\right) \]
    2. div-invN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\left(\frac{1}{\frac{1}{2} \cdot \frac{1}{a}}\right)\right)\right) \]
    3. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\left(\frac{\frac{1}{\frac{1}{2}}}{\frac{1}{a}}\right)\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\left(\frac{2}{\frac{1}{a}}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(2, \left(\frac{1}{a}\right)\right)\right)\right) \]
    6. /-lowering-/.f6498.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cbrt.f64}\left(g\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(1, a\right)\right)\right)\right) \]
  10. Applied egg-rr98.8%

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

Alternative 2: 98.7% accurate, 0.5× speedup?

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

\\
\sqrt[3]{\frac{g}{-2}} \cdot \sqrt[3]{\frac{-1}{a}}
\end{array}
Derivation
  1. Initial program 74.3%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/r*N/A

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left({\left(\mathsf{neg}\left(\frac{g}{2}\right)\right)}^{\frac{1}{3}}\right), \color{blue}{\left(\sqrt[3]{\frac{1}{\mathsf{neg}\left(a\right)}}\right)}\right) \]
    7. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(\mathsf{neg}\left(\frac{g}{2}\right)\right), \frac{1}{3}\right), \left(\sqrt[3]{\color{blue}{\frac{1}{\mathsf{neg}\left(a\right)}}}\right)\right) \]
    8. distribute-neg-frac2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(\frac{g}{\mathsf{neg}\left(2\right)}\right), \frac{1}{3}\right), \left(\sqrt[3]{\frac{\color{blue}{1}}{\mathsf{neg}\left(a\right)}}\right)\right) \]
    9. /-lowering-/.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \left(\sqrt[3]{\frac{1}{\mathsf{neg}\left(a\right)}}\right)\right) \]
    11. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\left(\frac{1}{\mathsf{neg}\left(a\right)}\right)\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(a\right)}\right)\right)\right) \]
    13. frac-2negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\left(\frac{-1}{a}\right)\right)\right) \]
    14. /-lowering-/.f6446.4%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{/.f64}\left(g, -2\right), \frac{1}{3}\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(-1, a\right)\right)\right) \]
  4. Applied egg-rr46.4%

    \[\leadsto \color{blue}{{\left(\frac{g}{-2}\right)}^{0.3333333333333333} \cdot \sqrt[3]{\frac{-1}{a}}} \]
  5. Step-by-step derivation
    1. unpow1/3N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{g}{-2}}\right), \mathsf{cbrt.f64}\left(\color{blue}{\mathsf{/.f64}\left(-1, a\right)}\right)\right) \]
    2. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(\frac{g}{-2}\right)\right), \mathsf{cbrt.f64}\left(\color{blue}{\mathsf{/.f64}\left(-1, a\right)}\right)\right) \]
    3. /-lowering-/.f6498.8%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, -2\right)\right), \mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(\color{blue}{-1}, a\right)\right)\right) \]
  6. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{-2}}} \cdot \sqrt[3]{\frac{-1}{a}} \]
  7. Add Preprocessing

Alternative 3: 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 74.3%

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

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{1}{\frac{2 \cdot a}{g}}\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{1}{2 \cdot a} \cdot g\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{2 \cdot a}\right), g\right)\right) \]
    4. associate-/r*N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{\frac{1}{2}}{a}\right), g\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{2}\right), a\right), g\right)\right) \]
    6. metadata-eval74.3%

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, a\right), g\right)\right) \]
  4. Applied egg-rr74.3%

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

      \[\leadsto \mathsf{cbrt.f64}\left(\left(g \cdot \frac{\frac{1}{2}}{a}\right)\right) \]
    2. frac-2negN/A

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

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{g \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}{\mathsf{neg}\left(a\right)}\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{g \cdot \frac{-1}{2}}{\mathsf{neg}\left(a\right)}\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{g \cdot \frac{1}{-2}}{\mathsf{neg}\left(a\right)}\right)\right) \]
    6. div-invN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{\frac{g}{-2}}{\mathsf{neg}\left(a\right)}\right)\right) \]
    7. distribute-frac-neg2N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{\frac{g}{-2}}{a}\right)\right)\right) \]
    8. clear-numN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{1}{\frac{a}{\frac{g}{-2}}}\right)\right)\right) \]
    9. *-inversesN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{\frac{g}{g}}{\frac{a}{\frac{g}{-2}}}\right)\right)\right) \]
    10. un-div-invN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{g}{g} \cdot \frac{1}{\frac{a}{\frac{g}{-2}}}\right)\right)\right) \]
    11. clear-numN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{g}{g} \cdot \frac{\frac{g}{-2}}{a}\right)\right)\right) \]
    12. associate-/l/N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{g}{g} \cdot \frac{g}{a \cdot -2}\right)\right)\right) \]
    13. times-fracN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{g \cdot g}{g \cdot \left(a \cdot -2\right)}\right)\right)\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\mathsf{neg}\left(\frac{g \cdot g}{\left(a \cdot -2\right) \cdot g}\right)\right)\right) \]
    15. distribute-frac-neg2N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{g \cdot g}{\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)}\right)\right) \]
    16. div-invN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\left(g \cdot g\right) \cdot \frac{1}{\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)}\right)\right) \]
    17. associate-*l*N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(g \cdot \left(g \cdot \frac{1}{\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)}\right)\right)\right) \]
    18. *-lowering-*.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \left(g \cdot \frac{1}{\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)}\right)\right)\right) \]
    19. *-lowering-*.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \left(\frac{1}{\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)}\right)\right)\right)\right) \]
    20. metadata-evalN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)}\right)\right)\right)\right) \]
    21. frac-2negN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)\right)\right)}\right)\right)\right)\right) \]
    22. metadata-evalN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)\right)\right)}\right)\right)\right)\right) \]
    23. metadata-evalN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \left(\frac{-1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(a \cdot -2\right) \cdot g\right)\right)\right)}\right)\right)\right)\right) \]
    24. remove-double-negN/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \left(\frac{-1}{\left(a \cdot -2\right) \cdot g}\right)\right)\right)\right) \]
    25. /-lowering-/.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(g, \mathsf{*.f64}\left(g, \mathsf{/.f64}\left(-1, \left(\left(a \cdot -2\right) \cdot g\right)\right)\right)\right)\right) \]
  6. Applied egg-rr54.8%

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{g \cdot \frac{-1}{a \cdot \left(g \cdot -2\right)}}\right), \left({\color{blue}{g}}^{\frac{1}{3}}\right)\right) \]
    6. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(g \cdot \frac{-1}{a \cdot \left(g \cdot -2\right)}\right)\right), \left({\color{blue}{g}}^{\frac{1}{3}}\right)\right) \]
    7. frac-2negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(g \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(a \cdot \left(g \cdot -2\right)\right)}\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(g \cdot \frac{1}{\mathsf{neg}\left(a \cdot \left(g \cdot -2\right)\right)}\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    9. un-div-invN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(\frac{g}{\mathsf{neg}\left(a \cdot \left(g \cdot -2\right)\right)}\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    10. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \left(\mathsf{neg}\left(a \cdot \left(g \cdot -2\right)\right)\right)\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    11. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \left(a \cdot \left(\mathsf{neg}\left(g \cdot -2\right)\right)\right)\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \mathsf{*.f64}\left(a, \left(\mathsf{neg}\left(g \cdot -2\right)\right)\right)\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    13. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \mathsf{*.f64}\left(a, \left(g \cdot \left(\mathsf{neg}\left(-2\right)\right)\right)\right)\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \mathsf{*.f64}\left(a, \left(g \cdot 2\right)\right)\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    15. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(g, 2\right)\right)\right)\right), \left({g}^{\frac{1}{3}}\right)\right) \]
    16. pow1/3N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(g, 2\right)\right)\right)\right), \left(\sqrt[3]{g}\right)\right) \]
    17. cbrt-lowering-cbrt.f6479.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(g, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(g, 2\right)\right)\right)\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
  8. Applied egg-rr79.0%

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{\frac{g}{a}}{g \cdot 2}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    2. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{1}{\frac{g \cdot 2}{\frac{g}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    3. cbrt-divN/A

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{g \cdot 2}{g \cdot \frac{1}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    5. times-fracN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{g}{g} \cdot \frac{2}{\frac{1}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    6. un-div-invN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\left(g \cdot \frac{1}{g}\right) \cdot \frac{2}{\frac{1}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    7. rgt-mult-inverseN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{1 \cdot \frac{2}{\frac{1}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{1 \cdot \frac{\frac{1}{\frac{1}{2}}}{\frac{1}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    9. associate-/r*N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{1 \cdot \frac{1}{\frac{1}{2} \cdot \frac{1}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    10. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{1 \cdot \frac{1}{\frac{\frac{1}{2}}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    11. div-invN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{1}{\frac{\frac{1}{2}}{a}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    12. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{1}{\frac{1}{\frac{a}{\frac{1}{2}}}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    13. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{\frac{a}{\frac{1}{2}}}{1}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    14. cbrt-divN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{1}{\frac{\frac{a}{\frac{1}{2}}}{1}}}\right), \mathsf{cbrt.f64}\left(\color{blue}{g}\right)\right) \]
    15. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{1}{\frac{a}{\frac{1}{2}}}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    16. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt[3]{\frac{\frac{1}{2}}{a}}\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
    17. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\left(\frac{\frac{1}{2}}{a}\right)\right), \mathsf{cbrt.f64}\left(\color{blue}{g}\right)\right) \]
    18. /-lowering-/.f6498.8%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, a\right)\right), \mathsf{cbrt.f64}\left(g\right)\right) \]
  10. Applied egg-rr98.8%

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

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

Alternative 4: 76.4% 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 74.3%

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

Alternative 5: 76.4% accurate, 1.0× speedup?

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

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

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{1}{\frac{2 \cdot a}{g}}\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\left(\frac{1}{2 \cdot a} \cdot g\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{2 \cdot a}\right), g\right)\right) \]
    4. associate-/r*N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{\frac{1}{2}}{a}\right), g\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{2}\right), a\right), g\right)\right) \]
    6. metadata-eval74.3%

      \[\leadsto \mathsf{cbrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, a\right), g\right)\right) \]
  4. Applied egg-rr74.3%

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

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

Reproduce

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