2-ancestry mixing, zero discriminant

Percentage Accurate: 75.3% → 98.7%
Time: 1.7s
Alternatives: 4
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 4 alternatives:

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

Initial Program: 75.3% 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 75.3%

    \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
  2. Add Preprocessing
  3. 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. *-commutativeN/A

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

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

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

    \[\leadsto \frac{\sqrt[3]{\color{blue}{g}}}{\sqrt[3]{a \cdot 2}} \]
  6. Step-by-step derivation
    1. Applied rewrites98.6%

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

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

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

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

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

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

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

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

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

    Alternative 2: 98.7% accurate, 0.5× 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 75.3%

      \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
    2. Add Preprocessing
    3. 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}}} \]
    4. Applied rewrites98.7%

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

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

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

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

    Alternative 3: 98.6% accurate, 0.5× 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 75.3%

      \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
    2. Add Preprocessing
    3. 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-+.f6475.3

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

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

      \[\leadsto \sqrt[3]{\frac{\color{blue}{g}}{a + a}} \]
    6. Step-by-step derivation
      1. Applied rewrites75.3%

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

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{a} + a}} \]
      3. Step-by-step derivation
        1. Applied rewrites75.3%

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

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

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

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

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

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

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

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

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

          \[\sqrt[3]{\frac{g}{2 \cdot a}} \]
        2. Add Preprocessing
        3. 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-+.f6475.3

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

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

        Reproduce

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