
(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 13 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 (+ (* (* (cbrt g) (cbrt (/ 1.0 a))) (* (cbrt -0.5) (cbrt 2.0))) (* (/ (pow (cbrt h) 2.0) (* (cbrt g) (cbrt a))) (* (cbrt -0.5) (cbrt 0.5)))))
double code(double g, double h, double a) {
return ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * cbrt(2.0))) + ((pow(cbrt(h), 2.0) / (cbrt(g) * cbrt(a))) * (cbrt(-0.5) * cbrt(0.5)));
}
public static double code(double g, double h, double a) {
return ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.cbrt(2.0))) + ((Math.pow(Math.cbrt(h), 2.0) / (Math.cbrt(g) * Math.cbrt(a))) * (Math.cbrt(-0.5) * Math.cbrt(0.5)));
}
function code(g, h, a) return Float64(Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * cbrt(2.0))) + Float64(Float64((cbrt(h) ^ 2.0) / Float64(cbrt(g) * cbrt(a))) * Float64(cbrt(-0.5) * cbrt(0.5)))) end
code[g_, h_, a_] := N[(N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Power[h, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) + \frac{{\left(\sqrt[3]{h}\right)}^{2}}{\sqrt[3]{g} \cdot \sqrt[3]{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{0.5}\right)
\end{array}
Initial program 42.5%
Simplified42.5%
Taylor expanded in h around 0 67.4%
pow1/332.5%
div-inv32.5%
unpow-prod-down18.3%
pow1/340.1%
Applied egg-rr40.1%
unpow1/388.5%
Simplified88.5%
cbrt-div89.4%
pow289.4%
cbrt-prod93.5%
pow293.5%
Applied egg-rr93.5%
Applied egg-rr98.0%
(FPCore (g h a)
:precision binary64
(if (<= (* h h) 1e-188)
(fma
(cbrt g)
(/ (cbrt -1.0) (cbrt a))
(* (cbrt -0.25) (cbrt (* (/ h g) (/ h a)))))
(+
(*
(* (cbrt g) (cbrt (/ 1.0 a)))
(* (cbrt -0.5) (pow 2.0 0.3333333333333333)))
(* (* (cbrt -0.5) (cbrt 0.5)) (/ (pow (cbrt h) 2.0) (cbrt (* g a)))))))
double code(double g, double h, double a) {
double tmp;
if ((h * h) <= 1e-188) {
tmp = fma(cbrt(g), (cbrt(-1.0) / cbrt(a)), (cbrt(-0.25) * cbrt(((h / g) * (h / a)))));
} else {
tmp = ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * pow(2.0, 0.3333333333333333))) + ((cbrt(-0.5) * cbrt(0.5)) * (pow(cbrt(h), 2.0) / cbrt((g * a))));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (Float64(h * h) <= 1e-188) tmp = fma(cbrt(g), Float64(cbrt(-1.0) / cbrt(a)), Float64(cbrt(-0.25) * cbrt(Float64(Float64(h / g) * Float64(h / a))))); else tmp = Float64(Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * (2.0 ^ 0.3333333333333333))) + Float64(Float64(cbrt(-0.5) * cbrt(0.5)) * Float64((cbrt(h) ^ 2.0) / cbrt(Float64(g * a))))); end return tmp end
code[g_, h_, a_] := If[LessEqual[N[(h * h), $MachinePrecision], 1e-188], N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Power[h, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[(g * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \cdot h \leq 10^{-188}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, \frac{\sqrt[3]{-1}}{\sqrt[3]{a}}, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{h}{g} \cdot \frac{h}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot {2}^{0.3333333333333333}\right) + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{0.5}\right) \cdot \frac{{\left(\sqrt[3]{h}\right)}^{2}}{\sqrt[3]{g \cdot a}}\\
\end{array}
\end{array}
if (*.f64 h h) < 9.9999999999999995e-189Initial program 49.3%
Simplified49.3%
Taylor expanded in h around 0 71.0%
pow1/333.4%
div-inv33.4%
unpow-prod-down17.8%
pow1/342.8%
Applied egg-rr42.8%
unpow1/390.2%
Simplified90.2%
associate-*l*90.3%
fma-define90.3%
cbrt-div90.1%
metadata-eval90.1%
cbrt-unprod90.7%
metadata-eval90.7%
*-commutative90.7%
cbrt-unprod90.7%
metadata-eval90.7%
Applied egg-rr90.7%
associate-*l/90.7%
*-lft-identity90.7%
*-commutative90.7%
associate-/r*97.6%
Simplified97.6%
Applied egg-rr98.1%
if 9.9999999999999995e-189 < (*.f64 h h) Initial program 32.0%
Simplified32.0%
Taylor expanded in h around 0 61.9%
pow1/331.0%
div-inv31.0%
unpow-prod-down19.1%
pow1/335.9%
Applied egg-rr35.9%
unpow1/385.9%
Simplified85.9%
cbrt-div87.7%
pow287.7%
cbrt-prod96.7%
pow296.7%
Applied egg-rr96.7%
pow1/397.4%
Applied egg-rr97.4%
Final simplification97.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (+ g t_0)))
(if (<=
(+
(cbrt (* (/ 1.0 (* a 2.0)) (- t_0 g)))
(cbrt (* t_1 (/ -1.0 (* a 2.0)))))
(- INFINITY))
(+ (* (cbrt (/ 1.0 a)) (cbrt (- g))) (cbrt (* t_1 (/ -0.5 a))))
(+ (cbrt (* (/ 0.5 a) (* g -2.0))) (cbrt (* (/ -0.5 a) (- g g)))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = g + t_0;
double tmp;
if ((cbrt(((1.0 / (a * 2.0)) * (t_0 - g))) + cbrt((t_1 * (-1.0 / (a * 2.0))))) <= -((double) INFINITY)) {
tmp = (cbrt((1.0 / a)) * cbrt(-g)) + cbrt((t_1 * (-0.5 / a)));
} else {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = g + t_0;
double tmp;
if ((Math.cbrt(((1.0 / (a * 2.0)) * (t_0 - g))) + Math.cbrt((t_1 * (-1.0 / (a * 2.0))))) <= -Double.POSITIVE_INFINITY) {
tmp = (Math.cbrt((1.0 / a)) * Math.cbrt(-g)) + Math.cbrt((t_1 * (-0.5 / a)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + Math.cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = Float64(g + t_0) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(a * 2.0)) * Float64(t_0 - g))) + cbrt(Float64(t_1 * Float64(-1.0 / Float64(a * 2.0))))) <= Float64(-Inf)) tmp = Float64(Float64(cbrt(Float64(1.0 / a)) * cbrt(Float64(-g))) + cbrt(Float64(t_1 * Float64(-0.5 / a)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g - g)))); 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]}, Block[{t$95$1 = N[(g + t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$1 * N[(-1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[(-g), 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$1 * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := g + t\_0\\
\mathbf{if}\;\sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(t\_0 - g\right)} + \sqrt[3]{t\_1 \cdot \frac{-1}{a \cdot 2}} \leq -\infty:\\
\;\;\;\;\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{-g} + \sqrt[3]{t\_1 \cdot \frac{-0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g - g\right)}\\
\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))))))) < -inf.0Initial program 4.2%
Simplified4.2%
Taylor expanded in g around -inf 4.2%
associate-*r/4.2%
neg-mul-14.2%
Simplified4.2%
pow1/30.2%
div-inv0.2%
unpow-prod-down0.0%
pow1/31.9%
Applied egg-rr1.9%
*-commutative1.9%
unpow1/355.8%
Simplified55.8%
if -inf.0 < (+.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 44.2%
Simplified44.2%
add-cbrt-cube30.6%
pow1/326.5%
pow326.5%
sqrt-pow226.5%
pow226.5%
pow226.5%
metadata-eval26.5%
Applied egg-rr26.5%
unpow1/331.3%
Simplified31.3%
Taylor expanded in g around -inf 22.7%
neg-mul-122.7%
Simplified22.7%
Taylor expanded in g around -inf 76.6%
*-commutative76.6%
Simplified76.6%
Final simplification75.7%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 a))))
(if (<= (* h h) 2e+227)
(fma
(cbrt g)
(* t_0 (cbrt -1.0))
(* (cbrt -0.25) (cbrt (/ (/ (pow h 2.0) g) a))))
(+
(* (* (cbrt g) t_0) (* (cbrt -0.5) (cbrt 2.0)))
(* (cbrt -0.25) (/ (pow (cbrt h) 2.0) (cbrt (* g a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt((1.0 / a));
double tmp;
if ((h * h) <= 2e+227) {
tmp = fma(cbrt(g), (t_0 * cbrt(-1.0)), (cbrt(-0.25) * cbrt(((pow(h, 2.0) / g) / a))));
} else {
tmp = ((cbrt(g) * t_0) * (cbrt(-0.5) * cbrt(2.0))) + (cbrt(-0.25) * (pow(cbrt(h), 2.0) / cbrt((g * a))));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(1.0 / a)) tmp = 0.0 if (Float64(h * h) <= 2e+227) tmp = fma(cbrt(g), Float64(t_0 * cbrt(-1.0)), Float64(cbrt(-0.25) * cbrt(Float64(Float64((h ^ 2.0) / g) / a)))); else tmp = Float64(Float64(Float64(cbrt(g) * t_0) * Float64(cbrt(-0.5) * cbrt(2.0))) + Float64(cbrt(-0.25) * Float64((cbrt(h) ^ 2.0) / cbrt(Float64(g * a))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(h * h), $MachinePrecision], 2e+227], N[(N[Power[g, 1/3], $MachinePrecision] * N[(t$95$0 * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[(N[Power[N[Power[h, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[(g * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{a}}\\
\mathbf{if}\;h \cdot h \leq 2 \cdot 10^{+227}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0 \cdot \sqrt[3]{-1}, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{\frac{{h}^{2}}{g}}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{g} \cdot t\_0\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) + \sqrt[3]{-0.25} \cdot \frac{{\left(\sqrt[3]{h}\right)}^{2}}{\sqrt[3]{g \cdot a}}\\
\end{array}
\end{array}
if (*.f64 h h) < 2.0000000000000002e227Initial program 46.1%
Simplified46.1%
Taylor expanded in h around 0 70.9%
pow1/334.3%
div-inv34.3%
unpow-prod-down19.1%
pow1/342.3%
Applied egg-rr42.3%
unpow1/392.6%
Simplified92.6%
associate-*l*92.6%
fma-define92.6%
cbrt-div92.4%
metadata-eval92.4%
cbrt-unprod93.0%
metadata-eval93.0%
*-commutative93.0%
cbrt-unprod93.0%
metadata-eval93.0%
Applied egg-rr93.0%
associate-*l/93.0%
*-lft-identity93.0%
*-commutative93.0%
associate-/r*97.8%
Simplified97.8%
Taylor expanded in a around 0 97.9%
if 2.0000000000000002e227 < (*.f64 h h) Initial program 0.0%
Simplified0.0%
Taylor expanded in h around 0 26.4%
pow1/310.5%
div-inv10.5%
unpow-prod-down9.6%
pow1/314.1%
Applied egg-rr14.1%
unpow1/340.3%
Simplified40.3%
cbrt-div49.7%
pow249.7%
cbrt-prod94.9%
pow294.9%
Applied egg-rr94.9%
pow194.9%
cbrt-unprod94.9%
metadata-eval94.9%
Applied egg-rr94.9%
unpow194.9%
Simplified94.9%
Final simplification97.6%
(FPCore (g h a)
:precision binary64
(if (<= (* h h) 4e+176)
(fma
(cbrt g)
(* (cbrt (/ 1.0 a)) (cbrt -1.0))
(* (cbrt -0.25) (cbrt (/ (/ (pow h 2.0) g) a))))
(fma
(cbrt g)
(/ (cbrt -1.0) (cbrt a))
(* (cbrt -0.25) (cbrt (/ (/ (/ g h) h) a))))))
double code(double g, double h, double a) {
double tmp;
if ((h * h) <= 4e+176) {
tmp = fma(cbrt(g), (cbrt((1.0 / a)) * cbrt(-1.0)), (cbrt(-0.25) * cbrt(((pow(h, 2.0) / g) / a))));
} else {
tmp = fma(cbrt(g), (cbrt(-1.0) / cbrt(a)), (cbrt(-0.25) * cbrt((((g / h) / h) / a))));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (Float64(h * h) <= 4e+176) tmp = fma(cbrt(g), Float64(cbrt(Float64(1.0 / a)) * cbrt(-1.0)), Float64(cbrt(-0.25) * cbrt(Float64(Float64((h ^ 2.0) / g) / a)))); else tmp = fma(cbrt(g), Float64(cbrt(-1.0) / cbrt(a)), Float64(cbrt(-0.25) * cbrt(Float64(Float64(Float64(g / h) / h) / a)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[N[(h * h), $MachinePrecision], 4e+176], N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(N[(g / h), $MachinePrecision] / h), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \cdot h \leq 4 \cdot 10^{+176}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, \sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{-1}, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{\frac{{h}^{2}}{g}}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, \frac{\sqrt[3]{-1}}{\sqrt[3]{a}}, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{\frac{\frac{g}{h}}{h}}{a}}\right)\\
\end{array}
\end{array}
if (*.f64 h h) < 4e176Initial program 47.1%
Simplified47.1%
Taylor expanded in h around 0 71.1%
pow1/335.1%
div-inv35.1%
unpow-prod-down19.5%
pow1/341.6%
Applied egg-rr41.6%
unpow1/392.5%
Simplified92.5%
associate-*l*92.5%
fma-define92.5%
cbrt-div92.3%
metadata-eval92.3%
cbrt-unprod92.9%
metadata-eval92.9%
*-commutative92.9%
cbrt-unprod92.9%
metadata-eval92.9%
Applied egg-rr92.9%
associate-*l/92.9%
*-lft-identity92.9%
*-commutative92.9%
associate-/r*97.8%
Simplified97.8%
Taylor expanded in a around 0 97.9%
if 4e176 < (*.f64 h h) Initial program 0.2%
Simplified0.2%
Taylor expanded in h around 0 33.2%
pow1/38.4%
div-inv8.4%
unpow-prod-down7.6%
pow1/325.8%
Applied egg-rr25.8%
unpow1/351.7%
Simplified51.7%
associate-*l*51.7%
fma-define51.7%
cbrt-div51.9%
metadata-eval51.9%
cbrt-unprod52.3%
metadata-eval52.3%
*-commutative52.3%
cbrt-unprod52.3%
metadata-eval52.3%
Applied egg-rr52.3%
associate-*l/52.3%
*-lft-identity52.3%
*-commutative52.3%
associate-/r*53.1%
Simplified53.1%
Applied egg-rr47.3%
associate-*l/47.3%
associate-*r/47.3%
rem-square-sqrt94.5%
Simplified94.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ (cbrt -1.0) (cbrt a))))
(if (<= (* h h) 4e+176)
(fma (cbrt g) t_0 (* (cbrt -0.25) (cbrt (/ (/ (pow h 2.0) g) a))))
(fma (cbrt g) t_0 (* (cbrt -0.25) (cbrt (/ (/ (/ g h) h) a)))))))
double code(double g, double h, double a) {
double t_0 = cbrt(-1.0) / cbrt(a);
double tmp;
if ((h * h) <= 4e+176) {
tmp = fma(cbrt(g), t_0, (cbrt(-0.25) * cbrt(((pow(h, 2.0) / g) / a))));
} else {
tmp = fma(cbrt(g), t_0, (cbrt(-0.25) * cbrt((((g / h) / h) / a))));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(cbrt(-1.0) / cbrt(a)) tmp = 0.0 if (Float64(h * h) <= 4e+176) tmp = fma(cbrt(g), t_0, Float64(cbrt(-0.25) * cbrt(Float64(Float64((h ^ 2.0) / g) / a)))); else tmp = fma(cbrt(g), t_0, Float64(cbrt(-0.25) * cbrt(Float64(Float64(Float64(g / h) / h) / a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[-1.0, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h * h), $MachinePrecision], 4e+176], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(N[(g / h), $MachinePrecision] / h), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt[3]{-1}}{\sqrt[3]{a}}\\
\mathbf{if}\;h \cdot h \leq 4 \cdot 10^{+176}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{\frac{{h}^{2}}{g}}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{\frac{\frac{g}{h}}{h}}{a}}\right)\\
\end{array}
\end{array}
if (*.f64 h h) < 4e176Initial program 47.1%
Simplified47.1%
Taylor expanded in h around 0 71.1%
pow1/335.1%
div-inv35.1%
unpow-prod-down19.5%
pow1/341.6%
Applied egg-rr41.6%
unpow1/392.5%
Simplified92.5%
associate-*l*92.5%
fma-define92.5%
cbrt-div92.3%
metadata-eval92.3%
cbrt-unprod92.9%
metadata-eval92.9%
*-commutative92.9%
cbrt-unprod92.9%
metadata-eval92.9%
Applied egg-rr92.9%
associate-*l/92.9%
*-lft-identity92.9%
*-commutative92.9%
associate-/r*97.8%
Simplified97.8%
if 4e176 < (*.f64 h h) Initial program 0.2%
Simplified0.2%
Taylor expanded in h around 0 33.2%
pow1/38.4%
div-inv8.4%
unpow-prod-down7.6%
pow1/325.8%
Applied egg-rr25.8%
unpow1/351.7%
Simplified51.7%
associate-*l*51.7%
fma-define51.7%
cbrt-div51.9%
metadata-eval51.9%
cbrt-unprod52.3%
metadata-eval52.3%
*-commutative52.3%
cbrt-unprod52.3%
metadata-eval52.3%
Applied egg-rr52.3%
associate-*l/52.3%
*-lft-identity52.3%
*-commutative52.3%
associate-/r*53.1%
Simplified53.1%
Applied egg-rr47.3%
associate-*l/47.3%
associate-*r/47.3%
rem-square-sqrt94.5%
Simplified94.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ (cbrt -1.0) (cbrt a))))
(if (<= (* h h) 2e+41)
(fma (cbrt g) t_0 (* (cbrt -0.25) (cbrt (* (/ h g) (/ h a)))))
(fma (cbrt g) t_0 (* (cbrt -0.25) (cbrt (/ (/ (/ g h) h) a)))))))
double code(double g, double h, double a) {
double t_0 = cbrt(-1.0) / cbrt(a);
double tmp;
if ((h * h) <= 2e+41) {
tmp = fma(cbrt(g), t_0, (cbrt(-0.25) * cbrt(((h / g) * (h / a)))));
} else {
tmp = fma(cbrt(g), t_0, (cbrt(-0.25) * cbrt((((g / h) / h) / a))));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(cbrt(-1.0) / cbrt(a)) tmp = 0.0 if (Float64(h * h) <= 2e+41) tmp = fma(cbrt(g), t_0, Float64(cbrt(-0.25) * cbrt(Float64(Float64(h / g) * Float64(h / a))))); else tmp = fma(cbrt(g), t_0, Float64(cbrt(-0.25) * cbrt(Float64(Float64(Float64(g / h) / h) / a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[-1.0, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h * h), $MachinePrecision], 2e+41], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(N[(g / h), $MachinePrecision] / h), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt[3]{-1}}{\sqrt[3]{a}}\\
\mathbf{if}\;h \cdot h \leq 2 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{h}{g} \cdot \frac{h}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{\frac{\frac{g}{h}}{h}}{a}}\right)\\
\end{array}
\end{array}
if (*.f64 h h) < 2.00000000000000001e41Initial program 47.8%
Simplified47.8%
Taylor expanded in h around 0 71.8%
pow1/334.2%
div-inv34.2%
unpow-prod-down19.2%
pow1/342.4%
Applied egg-rr42.4%
unpow1/392.1%
Simplified92.1%
associate-*l*92.1%
fma-define92.1%
cbrt-div91.9%
metadata-eval91.9%
cbrt-unprod92.5%
metadata-eval92.5%
*-commutative92.5%
cbrt-unprod92.5%
metadata-eval92.5%
Applied egg-rr92.5%
associate-*l/92.5%
*-lft-identity92.5%
*-commutative92.5%
associate-/r*97.8%
Simplified97.8%
Applied egg-rr98.1%
if 2.00000000000000001e41 < (*.f64 h h) Initial program 20.4%
Simplified20.4%
Taylor expanded in h around 0 49.4%
pow1/325.2%
div-inv25.2%
unpow-prod-down14.8%
pow1/330.6%
Applied egg-rr30.6%
unpow1/373.8%
Simplified73.8%
associate-*l*73.6%
fma-define73.6%
cbrt-div73.6%
metadata-eval73.6%
cbrt-unprod74.2%
metadata-eval74.2%
*-commutative74.2%
cbrt-unprod74.2%
metadata-eval74.2%
Applied egg-rr74.2%
associate-*l/74.2%
*-lft-identity74.2%
*-commutative74.2%
associate-/r*75.6%
Simplified75.6%
Applied egg-rr42.3%
associate-*l/42.3%
associate-*r/42.3%
rem-square-sqrt94.1%
Simplified94.1%
(FPCore (g h a) :precision binary64 (fma (cbrt g) (/ (cbrt -1.0) (cbrt a)) (* (cbrt -0.25) (cbrt (* (/ h g) (/ h a))))))
double code(double g, double h, double a) {
return fma(cbrt(g), (cbrt(-1.0) / cbrt(a)), (cbrt(-0.25) * cbrt(((h / g) * (h / a)))));
}
function code(g, h, a) return fma(cbrt(g), Float64(cbrt(-1.0) / cbrt(a)), Float64(cbrt(-0.25) * cbrt(Float64(Float64(h / g) * Float64(h / a))))) end
code[g_, h_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[-0.25, 1/3], $MachinePrecision] * N[Power[N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sqrt[3]{g}, \frac{\sqrt[3]{-1}}{\sqrt[3]{a}}, \sqrt[3]{-0.25} \cdot \sqrt[3]{\frac{h}{g} \cdot \frac{h}{a}}\right)
\end{array}
Initial program 42.5%
Simplified42.5%
Taylor expanded in h around 0 67.4%
pow1/332.5%
div-inv32.5%
unpow-prod-down18.3%
pow1/340.1%
Applied egg-rr40.1%
unpow1/388.5%
Simplified88.5%
associate-*l*88.5%
fma-define88.5%
cbrt-div88.3%
metadata-eval88.3%
cbrt-unprod89.0%
metadata-eval89.0%
*-commutative89.0%
cbrt-unprod89.0%
metadata-eval89.0%
Applied egg-rr89.0%
associate-*l/89.0%
*-lft-identity89.0%
*-commutative89.0%
associate-/r*93.4%
Simplified93.4%
Applied egg-rr94.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (* g -2.0))) (cbrt (* (/ -0.5 a) (- g g)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g * -2.0))) + cbrt(((-0.5 / a) * (g - g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g * -2.0))) + Math.cbrt(((-0.5 / a) * (g - g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g - g)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g - g\right)}
\end{array}
Initial program 42.5%
Simplified42.5%
add-cbrt-cube29.4%
pow1/325.5%
pow325.5%
sqrt-pow225.5%
pow225.5%
pow225.5%
metadata-eval25.5%
Applied egg-rr25.5%
unpow1/330.0%
Simplified30.0%
Taylor expanded in g around -inf 21.8%
neg-mul-121.8%
Simplified21.8%
Taylor expanded in g around -inf 73.5%
*-commutative73.5%
Simplified73.5%
Final simplification73.5%
(FPCore (g h a) :precision binary64 (* (cbrt -1.0) (cbrt (/ g a))))
double code(double g, double h, double a) {
return cbrt(-1.0) * cbrt((g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-1.0) * Math.cbrt((g / a));
}
function code(g, h, a) return Float64(cbrt(-1.0) * cbrt(Float64(g / a))) end
code[g_, h_, a_] := N[(N[Power[-1.0, 1/3], $MachinePrecision] * N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 42.5%
Simplified42.5%
Taylor expanded in h around 0 67.4%
pow1/332.5%
div-inv32.5%
unpow-prod-down18.3%
pow1/340.1%
Applied egg-rr40.1%
unpow1/388.5%
Simplified88.5%
associate-*l*88.5%
fma-define88.5%
cbrt-div88.3%
metadata-eval88.3%
cbrt-unprod89.0%
metadata-eval89.0%
*-commutative89.0%
cbrt-unprod89.0%
metadata-eval89.0%
Applied egg-rr89.0%
associate-*l/89.0%
*-lft-identity89.0%
*-commutative89.0%
associate-/r*93.4%
Simplified93.4%
Taylor expanded in g around inf 73.5%
Final simplification73.5%
(FPCore (g h a) :precision binary64 (* -2.0 (/ 1.0 (cbrt (/ a g)))))
double code(double g, double h, double a) {
return -2.0 * (1.0 / cbrt((a / g)));
}
public static double code(double g, double h, double a) {
return -2.0 * (1.0 / Math.cbrt((a / g)));
}
function code(g, h, a) return Float64(-2.0 * Float64(1.0 / cbrt(Float64(a / g)))) end
code[g_, h_, a_] := N[(-2.0 * N[(1.0 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}
\end{array}
Initial program 42.5%
Simplified42.5%
Taylor expanded in g around -inf 30.0%
associate-*r/30.0%
neg-mul-130.0%
Simplified30.0%
Taylor expanded in g around inf 15.2%
Taylor expanded in g around -inf 15.2%
*-commutative15.2%
Simplified15.2%
clear-num15.0%
cbrt-div15.4%
metadata-eval15.4%
Applied egg-rr15.4%
Final simplification15.4%
(FPCore (g h a) :precision binary64 (* -2.0 (cbrt (/ g a))))
double code(double g, double h, double a) {
return -2.0 * cbrt((g / a));
}
public static double code(double g, double h, double a) {
return -2.0 * Math.cbrt((g / a));
}
function code(g, h, a) return Float64(-2.0 * cbrt(Float64(g / a))) end
code[g_, h_, a_] := N[(-2.0 * N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 42.5%
Simplified42.5%
Taylor expanded in g around -inf 30.0%
associate-*r/30.0%
neg-mul-130.0%
Simplified30.0%
Taylor expanded in g around inf 15.2%
Taylor expanded in g around -inf 15.2%
*-commutative15.2%
Simplified15.2%
Final simplification15.2%
(FPCore (g h a) :precision binary64 (* (cbrt (* g a)) -2.0))
double code(double g, double h, double a) {
return cbrt((g * a)) * -2.0;
}
public static double code(double g, double h, double a) {
return Math.cbrt((g * a)) * -2.0;
}
function code(g, h, a) return Float64(cbrt(Float64(g * a)) * -2.0) end
code[g_, h_, a_] := N[(N[Power[N[(g * a), $MachinePrecision], 1/3], $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot a} \cdot -2
\end{array}
Initial program 42.5%
Simplified42.5%
Taylor expanded in g around -inf 30.0%
associate-*r/30.0%
neg-mul-130.0%
Simplified30.0%
Taylor expanded in g around inf 15.2%
Taylor expanded in g around -inf 15.2%
*-commutative15.2%
Simplified15.2%
Applied egg-rr5.7%
rem-cube-cbrt5.7%
*-commutative5.7%
Simplified5.7%
Final simplification5.7%
herbie shell --seed 2024121
(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))))))))