2-ancestry mixing, zero discriminant

Percentage Accurate: 76.8% → 98.7%
Time: 4.6s
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}

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: 76.8% accurate, 1.0× speedup?

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

\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}

Alternative 1: 98.7% accurate, 0.5× speedup?

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

\\
a\_s \cdot \left(g\_s \cdot \left(\left|\sqrt[3]{0.5 \cdot g\_m}\right| \cdot \sqrt[3]{\left|\frac{1}{a\_m}\right|}\right)\right)
\end{array}
Derivation
  1. Initial program 76.8%

    \[\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]{\color{blue}{\frac{g}{2 \cdot a}}} \]
    3. cbrt-divN/A

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{\color{blue}{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. Applied rewrites98.7%

    \[\leadsto \color{blue}{\left|\sqrt[3]{0.5 \cdot g}\right| \cdot \sqrt[3]{\left|\frac{1}{a}\right|}} \]
  5. Add Preprocessing

Alternative 2: 98.7% accurate, 0.6× speedup?

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

\\
a\_s \cdot \left(g\_s \cdot \frac{1}{\frac{\sqrt[3]{a\_m + a\_m}}{\sqrt[3]{g\_m}}}\right)
\end{array}
Derivation
  1. Initial program 76.8%

    \[\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]{\color{blue}{\frac{g}{2 \cdot a}}} \]
    3. cbrt-divN/A

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\sqrt[3]{\color{blue}{a + a}}}{\sqrt[3]{g}}} \]
    10. lower-+.f64N/A

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

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

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

Alternative 3: 98.7% accurate, 0.6× speedup?

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

\\
a\_s \cdot \left(g\_s \cdot \frac{\sqrt[3]{0.5 \cdot g\_m}}{\sqrt[3]{a\_m}}\right)
\end{array}
Derivation
  1. Initial program 76.8%

    \[\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]{\color{blue}{\frac{g}{2 \cdot a}}} \]
    3. lift-*.f64N/A

      \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{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. mult-flipN/A

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

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

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

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

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

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

Alternative 4: 98.7% accurate, 0.6× speedup?

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

\\
a\_s \cdot \left(g\_s \cdot \frac{\sqrt[3]{g\_m}}{\sqrt[3]{a\_m + a\_m}}\right)
\end{array}
Derivation
  1. Initial program 76.8%

    \[\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]{\color{blue}{\frac{g}{2 \cdot a}}} \]
    3. cbrt-divN/A

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{g}}{\sqrt[3]{\color{blue}{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 5: 96.6% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+96}:\\
\;\;\;\;\sqrt[3]{\frac{g\_m}{a\_m + a\_m}}\\

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


\end{array}\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1.99999999999999985e-104 or 5.0000000000000004e96 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a)))

    1. Initial program 76.8%

      \[\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. pow1/3N/A

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

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

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

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

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

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

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

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

      \[\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 \color{blue}{\left(\frac{g}{a + a}\right)} \cdot \frac{1}{3}} \]
      3. log-divN/A

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

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

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

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

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

    if 1.99999999999999985e-104 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 5.0000000000000004e96

    1. Initial program 76.8%

      \[\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.8

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

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

Alternative 6: 76.8% accurate, 1.0× speedup?

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

\\
a\_s \cdot \left(g\_s \cdot \sqrt[3]{\frac{g\_m}{a\_m + a\_m}}\right)
\end{array}
Derivation
  1. Initial program 76.8%

    \[\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.8

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

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

Reproduce

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