
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t\_0 \cdot \left(\left(-g\right) + t\_1\right)} + \sqrt[3]{t\_0 \cdot \left(\left(-g\right) - t\_1\right)}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t\_0 \cdot \left(\left(-g\right) + t\_1\right)} + \sqrt[3]{t\_0 \cdot \left(\left(-g\right) - t\_1\right)}
\end{array}
\end{array}
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_0 g)))
(cbrt (* (+ g t_0) (/ -1.0 (* 2.0 a)))))
5e+37)
(+
(* (cbrt (/ 0.5 a)) (cbrt (* g -2.0)))
(cbrt (* (/ (* 0.5 (pow h 2.0)) g) (/ -0.5 a))))
(- (cbrt (* (/ 0.5 a) (- g g))) (* (cbrt g) (cbrt (/ 1.0 a)))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + cbrt(((g + t_0) * (-1.0 / (2.0 * a))))) <= 5e+37) {
tmp = (cbrt((0.5 / a)) * cbrt((g * -2.0))) + cbrt((((0.5 * pow(h, 2.0)) / g) * (-0.5 / a)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) - (cbrt(g) * cbrt((1.0 / a)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double tmp;
if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + Math.cbrt(((g + t_0) * (-1.0 / (2.0 * a))))) <= 5e+37) {
tmp = (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + Math.cbrt((((0.5 * Math.pow(h, 2.0)) / g) * (-0.5 / a)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) - (Math.cbrt(g) * Math.cbrt((1.0 / a)));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_0 - g))) + cbrt(Float64(Float64(g + t_0) * Float64(-1.0 / Float64(2.0 * a))))) <= 5e+37) tmp = Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + cbrt(Float64(Float64(Float64(0.5 * (h ^ 2.0)) / g) * Float64(-0.5 / a)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - Float64(cbrt(g) * cbrt(Float64(1.0 / a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$0), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 5e+37], N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[(0.5 * N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t\_0 - g\right)} + \sqrt[3]{\left(g + t\_0\right) \cdot \frac{-1}{2 \cdot a}} \leq 5 \cdot 10^{+37}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\frac{0.5 \cdot {h}^{2}}{g} \cdot \frac{-0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.99999999999999989e37Initial program 77.7%
Simplified77.7%
cbrt-prod81.7%
pow281.7%
pow281.7%
Applied egg-rr81.7%
Taylor expanded in g around -inf 43.1%
associate-*r/43.1%
Simplified43.1%
Taylor expanded in g around -inf 96.3%
*-commutative96.3%
Simplified96.3%
if 4.99999999999999989e37 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 13.1%
Simplified13.1%
Taylor expanded in g around inf 8.2%
Taylor expanded in g around inf 64.3%
*-commutative64.3%
associate-*l*64.1%
Simplified64.1%
Applied egg-rr97.7%
Applied egg-rr44.1%
times-frac44.1%
pow-sqr44.1%
metadata-eval44.1%
unpow1/397.7%
neg-mul-197.7%
distribute-frac-neg297.7%
distribute-neg-frac97.7%
Simplified97.7%
frac-2neg97.7%
div-inv97.6%
remove-double-neg97.6%
Applied egg-rr97.6%
Taylor expanded in a around 0 97.7%
mul-1-neg97.7%
Simplified97.7%
Final simplification97.1%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (* (cbrt g) (cbrt (/ 1.0 a)))) (t_1 (sqrt (- (* g g) (* h h)))))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_1 g)))
(cbrt (* (+ g t_1) (/ -1.0 (* 2.0 a)))))
5e+33)
(+
(* (cbrt (* (/ h g) (/ h a))) (* (cbrt 0.5) (cbrt -0.5)))
(* t_0 (* (cbrt -0.5) (cbrt 2.0))))
(- (cbrt (* (/ 0.5 a) (- g g))) t_0))))
double code(double g, double h, double a) {
double t_0 = cbrt(g) * cbrt((1.0 / a));
double t_1 = sqrt(((g * g) - (h * h)));
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 5e+33) {
tmp = (cbrt(((h / g) * (h / a))) * (cbrt(0.5) * cbrt(-0.5))) + (t_0 * (cbrt(-0.5) * cbrt(2.0)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) - t_0;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(g) * Math.cbrt((1.0 / a));
double t_1 = Math.sqrt(((g * g) - (h * h)));
double tmp;
if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + Math.cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 5e+33) {
tmp = (Math.cbrt(((h / g) * (h / a))) * (Math.cbrt(0.5) * Math.cbrt(-0.5))) + (t_0 * (Math.cbrt(-0.5) * Math.cbrt(2.0)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) - t_0;
}
return tmp;
}
function code(g, h, a) t_0 = Float64(cbrt(g) * cbrt(Float64(1.0 / a))) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_1 - g))) + cbrt(Float64(Float64(g + t_1) * Float64(-1.0 / Float64(2.0 * a))))) <= 5e+33) tmp = Float64(Float64(cbrt(Float64(Float64(h / g) * Float64(h / a))) * Float64(cbrt(0.5) * cbrt(-0.5))) + Float64(t_0 * Float64(cbrt(-0.5) * cbrt(2.0)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - t_0); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$1), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 5e+33], N[(N[(N[Power[N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[0.5, 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t\_1 - g\right)} + \sqrt[3]{\left(g + t\_1\right) \cdot \frac{-1}{2 \cdot a}} \leq 5 \cdot 10^{+33}:\\
\;\;\;\;\sqrt[3]{\frac{h}{g} \cdot \frac{h}{a}} \cdot \left(\sqrt[3]{0.5} \cdot \sqrt[3]{-0.5}\right) + t\_0 \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - t\_0\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.99999999999999973e33Initial program 78.1%
Simplified78.1%
Taylor expanded in g around inf 51.8%
Taylor expanded in g around inf 81.4%
*-commutative81.4%
*-commutative81.4%
Simplified81.4%
pow1/346.7%
div-inv46.7%
unpow-prod-down35.3%
pow1/356.1%
Applied egg-rr56.1%
unpow1/392.3%
Simplified92.3%
unpow292.3%
times-frac96.6%
Applied egg-rr96.6%
if 4.99999999999999973e33 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 14.1%
Simplified14.1%
Taylor expanded in g around inf 9.0%
Taylor expanded in g around inf 64.6%
*-commutative64.6%
associate-*l*64.4%
Simplified64.4%
Applied egg-rr97.3%
Applied egg-rr44.5%
times-frac44.5%
pow-sqr44.5%
metadata-eval44.5%
unpow1/397.3%
neg-mul-197.3%
distribute-frac-neg297.3%
distribute-neg-frac97.3%
Simplified97.3%
frac-2neg97.3%
div-inv97.2%
remove-double-neg97.2%
Applied egg-rr97.2%
Taylor expanded in a around 0 97.3%
mul-1-neg97.3%
Simplified97.3%
Final simplification97.0%
(FPCore (g h a) :precision binary64 (- (cbrt (* (/ 0.5 a) (- g g))) (* (cbrt g) (cbrt (/ 1.0 a)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) - (cbrt(g) * cbrt((1.0 / a)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) - (Math.cbrt(g) * Math.cbrt((1.0 / a)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - Float64(cbrt(g) * cbrt(Float64(1.0 / a)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}
\end{array}
Initial program 42.6%
Simplified42.6%
Taylor expanded in g around inf 26.0%
Taylor expanded in g around inf 72.2%
*-commutative72.2%
associate-*l*72.0%
Simplified72.0%
Applied egg-rr95.4%
Applied egg-rr46.9%
times-frac46.9%
pow-sqr46.9%
metadata-eval46.9%
unpow1/395.4%
neg-mul-195.4%
distribute-frac-neg295.4%
distribute-neg-frac95.4%
Simplified95.4%
frac-2neg95.4%
div-inv95.4%
remove-double-neg95.4%
Applied egg-rr95.4%
Taylor expanded in a around 0 95.4%
mul-1-neg95.4%
Simplified95.4%
Final simplification95.4%
(FPCore (g h a) :precision binary64 (- (cbrt (* (/ 0.5 a) (- g g))) (/ (cbrt g) (cbrt a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) - (cbrt(g) / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) - (Math.cbrt(g) / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - Float64(cbrt(g) / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \frac{\sqrt[3]{g}}{\sqrt[3]{a}}
\end{array}
Initial program 42.6%
Simplified42.6%
Taylor expanded in g around inf 26.0%
Taylor expanded in g around inf 72.2%
*-commutative72.2%
associate-*l*72.0%
Simplified72.0%
Applied egg-rr95.4%
Applied egg-rr46.9%
times-frac46.9%
pow-sqr46.9%
metadata-eval46.9%
unpow1/395.4%
neg-mul-195.4%
distribute-frac-neg295.4%
distribute-neg-frac95.4%
Simplified95.4%
Final simplification95.4%
(FPCore (g h a) :precision binary64 (let* ((t_0 (cbrt (* (/ 0.5 a) (- g g))))) (if (<= a -9e-32) (+ (cbrt g) t_0) (+ t_0 (cbrt (- g))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((0.5 / a) * (g - g)));
double tmp;
if (a <= -9e-32) {
tmp = cbrt(g) + t_0;
} else {
tmp = t_0 + cbrt(-g);
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((0.5 / a) * (g - g)));
double tmp;
if (a <= -9e-32) {
tmp = Math.cbrt(g) + t_0;
} else {
tmp = t_0 + Math.cbrt(-g);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) tmp = 0.0 if (a <= -9e-32) tmp = Float64(cbrt(g) + t_0); else tmp = Float64(t_0 + cbrt(Float64(-g))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a, -9e-32], N[(N[Power[g, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision], N[(t$95$0 + N[Power[(-g), 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\
\mathbf{if}\;a \leq -9 \cdot 10^{-32}:\\
\;\;\;\;\sqrt[3]{g} + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \sqrt[3]{-g}\\
\end{array}
\end{array}
if a < -9.00000000000000009e-32Initial program 43.1%
Simplified43.1%
Taylor expanded in g around inf 24.9%
Taylor expanded in g around inf 92.7%
*-commutative92.7%
distribute-lft-in92.7%
Applied egg-rr92.7%
Simplified1.5%
add-cube-cbrt1.5%
distribute-rgt-neg-in1.5%
sqr-neg1.5%
add-cbrt-cube1.5%
neg-sub01.5%
sub-neg1.5%
add-sqr-sqrt0.7%
sqrt-unprod5.1%
sqr-neg5.1%
sqrt-unprod4.4%
add-sqr-sqrt8.3%
Applied egg-rr8.3%
+-lft-identity8.3%
Simplified8.3%
if -9.00000000000000009e-32 < a Initial program 42.4%
Simplified42.4%
Taylor expanded in g around inf 26.3%
Taylor expanded in g around inf 66.8%
*-commutative66.8%
distribute-lft-in66.7%
Applied egg-rr66.7%
Simplified6.3%
Final simplification6.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (/ -1.0 (cbrt (/ a g)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + (-1.0 / cbrt((a / g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + (-1.0 / Math.cbrt((a / g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(-1.0 / cbrt(Float64(a / g)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-1.0 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{-1}{\sqrt[3]{\frac{a}{g}}}
\end{array}
Initial program 42.6%
Simplified42.6%
Taylor expanded in g around inf 26.0%
Taylor expanded in g around inf 72.2%
*-commutative72.2%
associate-*l*72.0%
Simplified72.0%
Applied egg-rr95.4%
Applied egg-rr46.9%
Applied egg-rr73.2%
(FPCore (g h a) :precision binary64 (- (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ g a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) - cbrt((g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) - Math.cbrt((g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - cbrt(Float64(g / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 42.6%
Simplified42.6%
Taylor expanded in g around inf 26.0%
Taylor expanded in g around inf 72.8%
Taylor expanded in g around 0 72.9%
Simplified72.9%
Final simplification72.9%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) -1.0))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + -1.0;
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + -1.0;
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + -1.0) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + -1
\end{array}
Initial program 42.6%
Simplified42.6%
Taylor expanded in g around inf 26.0%
Taylor expanded in g around inf 72.8%
cbrt-prod95.3%
flip-+0.0%
cbrt-div0.0%
unpow20.0%
unpow20.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
add-cbrt-cube0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
add-cbrt-cube0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified4.5%
herbie shell --seed 2024107
(FPCore (g h a)
:name "2-ancestry mixing, positive discriminant"
:precision binary64
(+ (cbrt (* (/ 1.0 (* 2.0 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1.0 (* 2.0 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))