2-ancestry mixing, zero discriminant

Percentage Accurate: 76.1% → 98.7%
Time: 2.5s
Alternatives: 8
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}

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: 76.1% 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.4× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{\color{blue}{a + a}}} \]
    9. lower-+.f6498.7

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\color{blue}{\sqrt[3]{a + a}}} \]
    3. count-2-revN/A

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\color{blue}{\sqrt[3]{a}} \cdot \sqrt[3]{2}} \]
    8. lower-cbrt.f6498.2

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{a} \cdot \color{blue}{{2}^{\frac{1}{3}}}} \]
    3. lower-pow.f6498.7

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

    \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{a} \cdot \color{blue}{{2}^{0.3333333333333333}}} \]
  8. Add Preprocessing

Alternative 2: 98.7% accurate, 0.6× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}} \]
    6. lower-/.f64N/A

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

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\frac{g}{2}}}}{\sqrt[3]{a}} \]
    8. lower-/.f64N/A

      \[\leadsto \frac{\sqrt[3]{\color{blue}{\frac{g}{2}}}}{\sqrt[3]{a}} \]
    9. lower-cbrt.f6498.7

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

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

    \[\leadsto \frac{\sqrt[3]{\color{blue}{\frac{1}{2} \cdot g}}}{\sqrt[3]{a}} \]
  5. Step-by-step derivation
    1. lower-*.f6498.7

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

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

Alternative 3: 98.7% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{\color{blue}{a + a}}} \]
    9. lower-+.f6498.7

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

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

Alternative 4: 80.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\ t_1 := \sqrt[3]{\frac{g}{a + a}}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-106}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;e^{\left(\log \left(0.5 \cdot g\right) - \log a\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+101}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;e^{\left(\log g - \left(\log a + \log 2\right)\right) \cdot 0.3333333333333333}\\ \end{array} \end{array} \]
(FPCore (g a)
 :precision binary64
 (let* ((t_0 (cbrt (/ g (* 2.0 a)))) (t_1 (cbrt (/ g (+ a a)))))
   (if (<= t_0 -4e-106)
     t_1
     (if (<= t_0 5e-108)
       (exp (* (- (log (* 0.5 g)) (log a)) 0.3333333333333333))
       (if (<= t_0 5e+101)
         t_1
         (exp (* (- (log g) (+ (log a) (log 2.0))) 0.3333333333333333)))))))
double code(double g, double a) {
	double t_0 = cbrt((g / (2.0 * a)));
	double t_1 = cbrt((g / (a + a)));
	double tmp;
	if (t_0 <= -4e-106) {
		tmp = t_1;
	} else if (t_0 <= 5e-108) {
		tmp = exp(((log((0.5 * g)) - log(a)) * 0.3333333333333333));
	} else if (t_0 <= 5e+101) {
		tmp = t_1;
	} else {
		tmp = exp(((log(g) - (log(a) + log(2.0))) * 0.3333333333333333));
	}
	return tmp;
}
public static double code(double g, double a) {
	double t_0 = Math.cbrt((g / (2.0 * a)));
	double t_1 = Math.cbrt((g / (a + a)));
	double tmp;
	if (t_0 <= -4e-106) {
		tmp = t_1;
	} else if (t_0 <= 5e-108) {
		tmp = Math.exp(((Math.log((0.5 * g)) - Math.log(a)) * 0.3333333333333333));
	} else if (t_0 <= 5e+101) {
		tmp = t_1;
	} else {
		tmp = Math.exp(((Math.log(g) - (Math.log(a) + Math.log(2.0))) * 0.3333333333333333));
	}
	return tmp;
}
function code(g, a)
	t_0 = cbrt(Float64(g / Float64(2.0 * a)))
	t_1 = cbrt(Float64(g / Float64(a + a)))
	tmp = 0.0
	if (t_0 <= -4e-106)
		tmp = t_1;
	elseif (t_0 <= 5e-108)
		tmp = exp(Float64(Float64(log(Float64(0.5 * g)) - log(a)) * 0.3333333333333333));
	elseif (t_0 <= 5e+101)
		tmp = t_1;
	else
		tmp = exp(Float64(Float64(log(g) - Float64(log(a) + log(2.0))) * 0.3333333333333333));
	end
	return tmp
end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[t$95$0, -4e-106], t$95$1, If[LessEqual[t$95$0, 5e-108], N[Exp[N[(N[(N[Log[N[(0.5 * g), $MachinePrecision]], $MachinePrecision] - N[Log[a], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 5e+101], t$95$1, N[Exp[N[(N[(N[Log[g], $MachinePrecision] - N[(N[Log[a], $MachinePrecision] + N[Log[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
t_1 := \sqrt[3]{\frac{g}{a + a}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-106}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\
\;\;\;\;e^{\left(\log \left(0.5 \cdot g\right) - \log a\right) \cdot 0.3333333333333333}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;e^{\left(\log g - \left(\log a + \log 2\right)\right) \cdot 0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < -3.99999999999999976e-106 or 5e-108 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 4.99999999999999989e101

    1. Initial program 91.5%

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

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

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
      3. lower-+.f6491.5

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
    3. Applied rewrites91.5%

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

    if -3.99999999999999976e-106 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 5e-108

    1. Initial program 5.6%

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(\frac{g}{2 \cdot a}\right) \cdot \frac{1}{3}}} \]
      6. lower-exp.f64N/A

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

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{2 \cdot a}\right)} \cdot \frac{1}{3}} \]
      10. count-2-revN/A

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot \frac{1}{3}} \]
      11. lower-+.f644.5

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot 0.3333333333333333} \]
    3. Applied rewrites4.5%

      \[\leadsto \color{blue}{e^{\log \left(\frac{g}{a + a}\right) \cdot 0.3333333333333333}} \]
    4. Taylor expanded in g around -inf

      \[\leadsto e^{\color{blue}{\left(\log \left(\frac{\frac{-1}{2}}{a}\right) + -1 \cdot \log \left(\frac{-1}{g}\right)\right)} \cdot \frac{1}{3}} \]
    5. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{\color{blue}{\frac{-1}{2}}}{a}\right)\right) \cdot \frac{1}{3}} \]
      6. lower-/.f64N/A

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{\frac{-1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      7. lower-log.f64N/A

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{\frac{-1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      8. lower-/.f6422.4

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{-0.5}{a}\right)\right) \cdot 0.3333333333333333} \]
    6. Applied rewrites22.4%

      \[\leadsto e^{\color{blue}{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{-0.5}{a}\right)\right)} \cdot 0.3333333333333333} \]
    7. Taylor expanded in g around inf

      \[\leadsto e^{\color{blue}{\left(\log \left(\frac{\frac{1}{2}}{a}\right) + -1 \cdot \log \left(\frac{1}{g}\right)\right)} \cdot \frac{1}{3}} \]
    8. Step-by-step derivation
      1. diff-logN/A

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

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

        \[\leadsto e^{\left(-1 \cdot \log \left(\frac{1}{g}\right) + \color{blue}{\log \left(\frac{\frac{1}{2}}{a}\right)}\right) \cdot \frac{1}{3}} \]
      4. mul-1-negN/A

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

        \[\leadsto e^{\left(\left(-\log \left(\frac{1}{g}\right)\right) + \log \color{blue}{\left(\frac{\frac{1}{2}}{a}\right)}\right) \cdot \frac{1}{3}} \]
      6. log-recN/A

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

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

        \[\leadsto e^{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{\frac{1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      9. lower-log.f64N/A

        \[\leadsto e^{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{\frac{1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      10. lower-/.f6422.0

        \[\leadsto e^{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{0.5}{a}\right)\right) \cdot 0.3333333333333333} \]
    9. Applied rewrites22.0%

      \[\leadsto e^{\color{blue}{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{0.5}{a}\right)\right)} \cdot 0.3333333333333333} \]
    10. Applied rewrites22.0%

      \[\leadsto e^{\left(\log \left(0.5 \cdot g\right) - \color{blue}{\log a}\right) \cdot 0.3333333333333333} \]

    if 4.99999999999999989e101 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a)))

    1. Initial program 91.5%

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(\frac{g}{2 \cdot a}\right) \cdot \frac{1}{3}}} \]
      6. lower-exp.f64N/A

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

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{2 \cdot a}\right)} \cdot \frac{1}{3}} \]
      10. count-2-revN/A

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot \frac{1}{3}} \]
      11. lower-+.f6442.6

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot 0.3333333333333333} \]
    3. Applied rewrites42.6%

      \[\leadsto \color{blue}{e^{\log \left(\frac{g}{a + a}\right) \cdot 0.3333333333333333}} \]
    4. Step-by-step derivation
      1. lift-log.f64N/A

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{a + a}\right)} \cdot \frac{1}{3}} \]
      4. log-divN/A

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

        \[\leadsto e^{\color{blue}{\left(\log g - \log \left(a + a\right)\right)} \cdot \frac{1}{3}} \]
      6. lower-log.f64N/A

        \[\leadsto e^{\left(\color{blue}{\log g} - \log \left(a + a\right)\right) \cdot \frac{1}{3}} \]
      7. lower-log.f64N/A

        \[\leadsto e^{\left(\log g - \color{blue}{\log \left(a + a\right)}\right) \cdot \frac{1}{3}} \]
      8. lift-+.f6421.0

        \[\leadsto e^{\left(\log g - \log \color{blue}{\left(a + a\right)}\right) \cdot 0.3333333333333333} \]
    5. Applied rewrites21.0%

      \[\leadsto e^{\color{blue}{\left(\log g - \log \left(a + a\right)\right)} \cdot 0.3333333333333333} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto e^{\left(\log g - \color{blue}{\log \left(a + a\right)}\right) \cdot \frac{1}{3}} \]
      3. count-2-revN/A

        \[\leadsto e^{\left(\log g - \log \color{blue}{\left(2 \cdot a\right)}\right) \cdot \frac{1}{3}} \]
      4. sum-logN/A

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

        \[\leadsto e^{\left(\log g - \color{blue}{\left(\log a + \log 2\right)}\right) \cdot \frac{1}{3}} \]
      6. lower-+.f64N/A

        \[\leadsto e^{\left(\log g - \color{blue}{\left(\log a + \log 2\right)}\right) \cdot \frac{1}{3}} \]
      7. lower-log.f64N/A

        \[\leadsto e^{\left(\log g - \left(\color{blue}{\log a} + \log 2\right)\right) \cdot \frac{1}{3}} \]
      8. lower-log.f6421.0

        \[\leadsto e^{\left(\log g - \left(\log a + \color{blue}{\log 2}\right)\right) \cdot 0.3333333333333333} \]
    7. Applied rewrites21.0%

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

Alternative 5: 80.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\ t_1 := \sqrt[3]{\frac{g}{a + a}}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-106}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;e^{\left(\log \left(0.5 \cdot g\right) - \log a\right) \cdot 0.3333333333333333}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+101}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;e^{\left(\log g - \log \left(a + a\right)\right) \cdot 0.3333333333333333}\\ \end{array} \end{array} \]
(FPCore (g a)
 :precision binary64
 (let* ((t_0 (cbrt (/ g (* 2.0 a)))) (t_1 (cbrt (/ g (+ a a)))))
   (if (<= t_0 -4e-106)
     t_1
     (if (<= t_0 5e-108)
       (exp (* (- (log (* 0.5 g)) (log a)) 0.3333333333333333))
       (if (<= t_0 5e+101)
         t_1
         (exp (* (- (log g) (log (+ a a))) 0.3333333333333333)))))))
double code(double g, double a) {
	double t_0 = cbrt((g / (2.0 * a)));
	double t_1 = cbrt((g / (a + a)));
	double tmp;
	if (t_0 <= -4e-106) {
		tmp = t_1;
	} else if (t_0 <= 5e-108) {
		tmp = exp(((log((0.5 * g)) - log(a)) * 0.3333333333333333));
	} else if (t_0 <= 5e+101) {
		tmp = t_1;
	} else {
		tmp = exp(((log(g) - log((a + a))) * 0.3333333333333333));
	}
	return tmp;
}
public static double code(double g, double a) {
	double t_0 = Math.cbrt((g / (2.0 * a)));
	double t_1 = Math.cbrt((g / (a + a)));
	double tmp;
	if (t_0 <= -4e-106) {
		tmp = t_1;
	} else if (t_0 <= 5e-108) {
		tmp = Math.exp(((Math.log((0.5 * g)) - Math.log(a)) * 0.3333333333333333));
	} else if (t_0 <= 5e+101) {
		tmp = t_1;
	} else {
		tmp = Math.exp(((Math.log(g) - Math.log((a + a))) * 0.3333333333333333));
	}
	return tmp;
}
function code(g, a)
	t_0 = cbrt(Float64(g / Float64(2.0 * a)))
	t_1 = cbrt(Float64(g / Float64(a + a)))
	tmp = 0.0
	if (t_0 <= -4e-106)
		tmp = t_1;
	elseif (t_0 <= 5e-108)
		tmp = exp(Float64(Float64(log(Float64(0.5 * g)) - log(a)) * 0.3333333333333333));
	elseif (t_0 <= 5e+101)
		tmp = t_1;
	else
		tmp = exp(Float64(Float64(log(g) - log(Float64(a + a))) * 0.3333333333333333));
	end
	return tmp
end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[t$95$0, -4e-106], t$95$1, If[LessEqual[t$95$0, 5e-108], N[Exp[N[(N[(N[Log[N[(0.5 * g), $MachinePrecision]], $MachinePrecision] - N[Log[a], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 5e+101], t$95$1, N[Exp[N[(N[(N[Log[g], $MachinePrecision] - N[Log[N[(a + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
t_1 := \sqrt[3]{\frac{g}{a + a}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-106}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\
\;\;\;\;e^{\left(\log \left(0.5 \cdot g\right) - \log a\right) \cdot 0.3333333333333333}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;e^{\left(\log g - \log \left(a + a\right)\right) \cdot 0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < -3.99999999999999976e-106 or 5e-108 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 4.99999999999999989e101

    1. Initial program 91.5%

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

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

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
      3. lower-+.f6491.5

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
    3. Applied rewrites91.5%

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

    if -3.99999999999999976e-106 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 5e-108

    1. Initial program 5.6%

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(\frac{g}{2 \cdot a}\right) \cdot \frac{1}{3}}} \]
      6. lower-exp.f64N/A

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

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{2 \cdot a}\right)} \cdot \frac{1}{3}} \]
      10. count-2-revN/A

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot \frac{1}{3}} \]
      11. lower-+.f644.5

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot 0.3333333333333333} \]
    3. Applied rewrites4.5%

      \[\leadsto \color{blue}{e^{\log \left(\frac{g}{a + a}\right) \cdot 0.3333333333333333}} \]
    4. Taylor expanded in g around -inf

      \[\leadsto e^{\color{blue}{\left(\log \left(\frac{\frac{-1}{2}}{a}\right) + -1 \cdot \log \left(\frac{-1}{g}\right)\right)} \cdot \frac{1}{3}} \]
    5. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{\color{blue}{\frac{-1}{2}}}{a}\right)\right) \cdot \frac{1}{3}} \]
      6. lower-/.f64N/A

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{\frac{-1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      7. lower-log.f64N/A

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{\frac{-1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      8. lower-/.f6422.4

        \[\leadsto e^{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{-0.5}{a}\right)\right) \cdot 0.3333333333333333} \]
    6. Applied rewrites22.4%

      \[\leadsto e^{\color{blue}{\left(\left(-\log \left(\frac{-1}{g}\right)\right) + \log \left(\frac{-0.5}{a}\right)\right)} \cdot 0.3333333333333333} \]
    7. Taylor expanded in g around inf

      \[\leadsto e^{\color{blue}{\left(\log \left(\frac{\frac{1}{2}}{a}\right) + -1 \cdot \log \left(\frac{1}{g}\right)\right)} \cdot \frac{1}{3}} \]
    8. Step-by-step derivation
      1. diff-logN/A

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

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

        \[\leadsto e^{\left(-1 \cdot \log \left(\frac{1}{g}\right) + \color{blue}{\log \left(\frac{\frac{1}{2}}{a}\right)}\right) \cdot \frac{1}{3}} \]
      4. mul-1-negN/A

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

        \[\leadsto e^{\left(\left(-\log \left(\frac{1}{g}\right)\right) + \log \color{blue}{\left(\frac{\frac{1}{2}}{a}\right)}\right) \cdot \frac{1}{3}} \]
      6. log-recN/A

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

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

        \[\leadsto e^{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{\frac{1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      9. lower-log.f64N/A

        \[\leadsto e^{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{\frac{1}{2}}{a}\right)\right) \cdot \frac{1}{3}} \]
      10. lower-/.f6422.0

        \[\leadsto e^{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{0.5}{a}\right)\right) \cdot 0.3333333333333333} \]
    9. Applied rewrites22.0%

      \[\leadsto e^{\color{blue}{\left(\left(-\left(-\log g\right)\right) + \log \left(\frac{0.5}{a}\right)\right)} \cdot 0.3333333333333333} \]
    10. Applied rewrites22.0%

      \[\leadsto e^{\left(\log \left(0.5 \cdot g\right) - \color{blue}{\log a}\right) \cdot 0.3333333333333333} \]

    if 4.99999999999999989e101 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a)))

    1. Initial program 91.5%

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(\frac{g}{2 \cdot a}\right) \cdot \frac{1}{3}}} \]
      6. lower-exp.f64N/A

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

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{2 \cdot a}\right)} \cdot \frac{1}{3}} \]
      10. count-2-revN/A

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot \frac{1}{3}} \]
      11. lower-+.f6442.6

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot 0.3333333333333333} \]
    3. Applied rewrites42.6%

      \[\leadsto \color{blue}{e^{\log \left(\frac{g}{a + a}\right) \cdot 0.3333333333333333}} \]
    4. Step-by-step derivation
      1. lift-log.f64N/A

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{a + a}\right)} \cdot \frac{1}{3}} \]
      4. log-divN/A

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

        \[\leadsto e^{\color{blue}{\left(\log g - \log \left(a + a\right)\right)} \cdot \frac{1}{3}} \]
      6. lower-log.f64N/A

        \[\leadsto e^{\left(\color{blue}{\log g} - \log \left(a + a\right)\right) \cdot \frac{1}{3}} \]
      7. lower-log.f64N/A

        \[\leadsto e^{\left(\log g - \color{blue}{\log \left(a + a\right)}\right) \cdot \frac{1}{3}} \]
      8. lift-+.f6421.0

        \[\leadsto e^{\left(\log g - \log \color{blue}{\left(a + a\right)}\right) \cdot 0.3333333333333333} \]
    5. Applied rewrites21.0%

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

Alternative 6: 80.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(\log g - \log \left(a + a\right)\right) \cdot 0.3333333333333333}\\ t_1 := \sqrt[3]{\frac{g}{2 \cdot a}}\\ t_2 := \sqrt[3]{\frac{g}{a + a}}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-106}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+101}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (g a)
 :precision binary64
 (let* ((t_0 (exp (* (- (log g) (log (+ a a))) 0.3333333333333333)))
        (t_1 (cbrt (/ g (* 2.0 a))))
        (t_2 (cbrt (/ g (+ a a)))))
   (if (<= t_1 -4e-106)
     t_2
     (if (<= t_1 5e-108) t_0 (if (<= t_1 5e+101) t_2 t_0)))))
double code(double g, double a) {
	double t_0 = exp(((log(g) - log((a + a))) * 0.3333333333333333));
	double t_1 = cbrt((g / (2.0 * a)));
	double t_2 = cbrt((g / (a + a)));
	double tmp;
	if (t_1 <= -4e-106) {
		tmp = t_2;
	} else if (t_1 <= 5e-108) {
		tmp = t_0;
	} else if (t_1 <= 5e+101) {
		tmp = t_2;
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double g, double a) {
	double t_0 = Math.exp(((Math.log(g) - Math.log((a + a))) * 0.3333333333333333));
	double t_1 = Math.cbrt((g / (2.0 * a)));
	double t_2 = Math.cbrt((g / (a + a)));
	double tmp;
	if (t_1 <= -4e-106) {
		tmp = t_2;
	} else if (t_1 <= 5e-108) {
		tmp = t_0;
	} else if (t_1 <= 5e+101) {
		tmp = t_2;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(g, a)
	t_0 = exp(Float64(Float64(log(g) - log(Float64(a + a))) * 0.3333333333333333))
	t_1 = cbrt(Float64(g / Float64(2.0 * a)))
	t_2 = cbrt(Float64(g / Float64(a + a)))
	tmp = 0.0
	if (t_1 <= -4e-106)
		tmp = t_2;
	elseif (t_1 <= 5e-108)
		tmp = t_0;
	elseif (t_1 <= 5e+101)
		tmp = t_2;
	else
		tmp = t_0;
	end
	return tmp
end
code[g_, a_] := Block[{t$95$0 = N[Exp[N[(N[(N[Log[g], $MachinePrecision] - N[Log[N[(a + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[t$95$1, -4e-106], t$95$2, If[LessEqual[t$95$1, 5e-108], t$95$0, If[LessEqual[t$95$1, 5e+101], t$95$2, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\left(\log g - \log \left(a + a\right)\right) \cdot 0.3333333333333333}\\
t_1 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
t_2 := \sqrt[3]{\frac{g}{a + a}}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-106}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-108}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+101}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < -3.99999999999999976e-106 or 5e-108 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 4.99999999999999989e101

    1. Initial program 91.5%

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

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

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
      3. lower-+.f6491.5

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
    3. Applied rewrites91.5%

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

    if -3.99999999999999976e-106 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 5e-108 or 4.99999999999999989e101 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a)))

    1. Initial program 5.7%

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\log \left(\frac{g}{2 \cdot a}\right) \cdot \frac{1}{3}}} \]
      6. lower-exp.f64N/A

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

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{2 \cdot a}\right)} \cdot \frac{1}{3}} \]
      10. count-2-revN/A

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot \frac{1}{3}} \]
      11. lower-+.f644.9

        \[\leadsto e^{\log \left(\frac{g}{\color{blue}{a + a}}\right) \cdot 0.3333333333333333} \]
    3. Applied rewrites4.9%

      \[\leadsto \color{blue}{e^{\log \left(\frac{g}{a + a}\right) \cdot 0.3333333333333333}} \]
    4. Step-by-step derivation
      1. lift-log.f64N/A

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

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

        \[\leadsto e^{\log \color{blue}{\left(\frac{g}{a + a}\right)} \cdot \frac{1}{3}} \]
      4. log-divN/A

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

        \[\leadsto e^{\color{blue}{\left(\log g - \log \left(a + a\right)\right)} \cdot \frac{1}{3}} \]
      6. lower-log.f64N/A

        \[\leadsto e^{\left(\color{blue}{\log g} - \log \left(a + a\right)\right) \cdot \frac{1}{3}} \]
      7. lower-log.f64N/A

        \[\leadsto e^{\left(\log g - \color{blue}{\log \left(a + a\right)}\right) \cdot \frac{1}{3}} \]
      8. lift-+.f6430.1

        \[\leadsto e^{\left(\log g - \log \color{blue}{\left(a + a\right)}\right) \cdot 0.3333333333333333} \]
    5. Applied rewrites30.1%

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

Alternative 7: 76.1% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
    3. lower-+.f6476.1

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a + a}}} \]
  3. Applied rewrites76.1%

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

Alternative 8: 4.8% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{\color{blue}{a + a}}} \]
    9. lower-+.f6498.7

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\color{blue}{\sqrt[3]{a + a}}} \]
    3. count-2-revN/A

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\color{blue}{\sqrt[3]{a}} \cdot \sqrt[3]{2}} \]
    8. lower-cbrt.f6498.2

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{a} \cdot \color{blue}{{2}^{\frac{1}{3}}}} \]
    3. lower-pow.f6498.7

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

    \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{a} \cdot \color{blue}{{2}^{0.3333333333333333}}} \]
  8. Step-by-step derivation
    1. lift-/.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{\color{blue}{a + a}}} \]
    10. cbrt-undivN/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a + a}}} \]
    11. rem-exp-logN/A

      \[\leadsto \sqrt[3]{\color{blue}{e^{\log \left(\frac{g}{a + a}\right)}}} \]
    12. diff-logN/A

      \[\leadsto \sqrt[3]{e^{\color{blue}{\log g - \log \left(a + a\right)}}} \]
    13. lower-cbrt.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{e^{\log g - \log \left(a + a\right)}}} \]
    14. diff-logN/A

      \[\leadsto \sqrt[3]{e^{\color{blue}{\log \left(\frac{g}{a + a}\right)}}} \]
    15. rem-exp-logN/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{a + a}}} \]
    16. flip-+N/A

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{\frac{a \cdot a - a \cdot a}{a - a}}}} \]
    17. +-inversesN/A

      \[\leadsto \sqrt[3]{\frac{g}{\frac{\color{blue}{0}}{a - a}}} \]
    18. metadata-evalN/A

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

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

      \[\leadsto \sqrt[3]{\frac{g}{\frac{1 \cdot 1 - \color{blue}{1 \cdot 1}}{a - a}}} \]
    21. +-inversesN/A

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

      \[\leadsto \sqrt[3]{\frac{g}{\frac{1 \cdot 1 - 1 \cdot 1}{\color{blue}{1 - 1}}}} \]
    23. flip-+N/A

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{1 + 1}}} \]
    24. metadata-evalN/A

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{2}}} \]
    25. lower-/.f644.8

      \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{2}}} \]
  9. Applied rewrites4.8%

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

Reproduce

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