
(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 10 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 (* (/ 0.5 a) (- g g))) (* (cbrt (/ -0.5 a)) (cbrt (+ g g)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + (cbrt((-0.5 / a)) * cbrt((g + g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + (Math.cbrt((-0.5 / a)) * Math.cbrt((g + g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(cbrt(Float64(-0.5 / a)) * cbrt(Float64(g + g)))) 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[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g + g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + g}
\end{array}
Initial program 45.1%
Simplified45.1%
*-commutative45.1%
cbrt-prod49.2%
pow249.2%
pow249.2%
Applied egg-rr49.2%
Taylor expanded in g around inf 32.6%
Taylor expanded in g around inf 95.0%
Final simplification95.0%
(FPCore (g h a) :precision binary64 (+ (/ (cbrt (- g)) (cbrt a)) (cbrt (* (- g g) (/ -0.5 a)))))
double code(double g, double h, double a) {
return (cbrt(-g) / cbrt(a)) + cbrt(((g - g) * (-0.5 / a)));
}
public static double code(double g, double h, double a) {
return (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(((g - g) * (-0.5 / a)));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))) end
code[g_, h_, a_] := N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around -inf 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in g around -inf 72.9%
neg-mul-172.9%
Simplified72.9%
associate-*l/72.9%
cbrt-div94.9%
*-commutative94.9%
associate-*r*94.9%
metadata-eval94.9%
neg-mul-194.9%
Applied egg-rr94.9%
Final simplification94.9%
(FPCore (g h a) :precision binary64 (if (or (<= a -38.0) (not (<= a 7e-79))) (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (/ (- g) a))) (+ (/ (cbrt (- g)) (cbrt a)) (cbrt -2.0))))
double code(double g, double h, double a) {
double tmp;
if ((a <= -38.0) || !(a <= 7e-79)) {
tmp = cbrt(((g - g) * (-0.5 / a))) + cbrt((-g / a));
} else {
tmp = (cbrt(-g) / cbrt(a)) + cbrt(-2.0);
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((a <= -38.0) || !(a <= 7e-79)) {
tmp = Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt((-g / a));
} else {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-2.0);
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if ((a <= -38.0) || !(a <= 7e-79)) tmp = Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(-g) / a))); else tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-2.0)); end return tmp end
code[g_, h_, a_] := If[Or[LessEqual[a, -38.0], N[Not[LessEqual[a, 7e-79]], $MachinePrecision]], N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -38 \lor \neg \left(a \leq 7 \cdot 10^{-79}\right):\\
\;\;\;\;\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-g}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-2}\\
\end{array}
\end{array}
if a < -38 or 7.00000000000000059e-79 < a Initial program 49.6%
Simplified49.6%
Taylor expanded in g around -inf 26.9%
*-commutative26.9%
Simplified26.9%
Taylor expanded in g around -inf 89.4%
neg-mul-189.4%
Simplified89.4%
associate-*l/89.4%
*-commutative89.4%
associate-*r*89.4%
metadata-eval89.4%
neg-mul-189.4%
Applied egg-rr89.4%
if -38 < a < 7.00000000000000059e-79Initial program 39.2%
Simplified39.2%
Taylor expanded in g around -inf 22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in g around inf 11.8%
add-sqr-sqrt5.0%
sqrt-unprod3.4%
*-commutative3.4%
*-commutative3.4%
swap-sqr2.8%
*-commutative2.8%
*-commutative2.8%
swap-sqr2.8%
metadata-eval2.8%
metadata-eval2.8%
swap-sqr2.8%
count-22.8%
count-22.8%
frac-times2.8%
metadata-eval2.8%
metadata-eval2.8%
frac-times2.8%
swap-sqr3.4%
sqrt-unprod5.0%
add-sqr-sqrt11.8%
expm1-log1p-u5.6%
Applied egg-rr0.0%
Simplified46.4%
add-sqr-sqrt18.8%
sqrt-unprod6.6%
swap-sqr4.2%
count-24.2%
count-24.2%
swap-sqr4.2%
metadata-eval4.2%
metadata-eval4.2%
swap-sqr4.2%
*-commutative4.2%
*-commutative4.2%
frac-times4.2%
metadata-eval4.2%
metadata-eval4.2%
frac-times4.2%
swap-sqr6.6%
*-commutative6.6%
*-commutative6.6%
Applied egg-rr89.2%
Final simplification89.3%
(FPCore (g h a) :precision binary64 (if (or (<= a -1.25e-46) (not (<= a 5e-12))) (+ (cbrt (* (/ 0.5 a) (* g -2.0))) (/ -2.0 (cbrt a))) (+ (cbrt g) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
double tmp;
if ((a <= -1.25e-46) || !(a <= 5e-12)) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + (-2.0 / cbrt(a));
} else {
tmp = cbrt(g) + cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((a <= -1.25e-46) || !(a <= 5e-12)) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + (-2.0 / Math.cbrt(a));
} else {
tmp = Math.cbrt(g) + Math.cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if ((a <= -1.25e-46) || !(a <= 5e-12)) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + Float64(-2.0 / cbrt(a))); else tmp = Float64(cbrt(g) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); end return tmp end
code[g_, h_, a_] := If[Or[LessEqual[a, -1.25e-46], N[Not[LessEqual[a, 5e-12]], $MachinePrecision]], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-2.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 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}
\mathbf{if}\;a \leq -1.25 \cdot 10^{-46} \lor \neg \left(a \leq 5 \cdot 10^{-12}\right):\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \frac{-2}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\end{array}
\end{array}
if a < -1.24999999999999998e-46 or 4.9999999999999997e-12 < a Initial program 45.8%
Simplified45.8%
Taylor expanded in g around -inf 24.6%
*-commutative24.6%
Simplified24.6%
Taylor expanded in g around inf 17.6%
expm1-log1p-u19.0%
expm1-udef19.0%
Applied egg-rr0.0%
Simplified72.9%
if -1.24999999999999998e-46 < a < 4.9999999999999997e-12Initial program 44.2%
Simplified44.2%
Taylor expanded in g around -inf 25.0%
*-commutative25.0%
Simplified25.0%
Taylor expanded in g around inf 12.4%
associate-*l/12.4%
clear-num12.4%
*-commutative12.4%
associate-*r*12.4%
metadata-eval12.4%
neg-mul-112.4%
Applied egg-rr12.4%
Simplified52.5%
Final simplification63.3%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (<= g -1.55e+15)
(+ (cbrt (/ (- g) a)) (cbrt -2.0))
(if (<= g 2.0) (+ (cbrt (- g)) t_0) (+ (cbrt -2.0) t_0)))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (g <= -1.55e+15) {
tmp = cbrt((-g / a)) + cbrt(-2.0);
} else if (g <= 2.0) {
tmp = cbrt(-g) + t_0;
} else {
tmp = cbrt(-2.0) + t_0;
}
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 (g <= -1.55e+15) {
tmp = Math.cbrt((-g / a)) + Math.cbrt(-2.0);
} else if (g <= 2.0) {
tmp = Math.cbrt(-g) + t_0;
} else {
tmp = Math.cbrt(-2.0) + t_0;
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if (g <= -1.55e+15) tmp = Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(-2.0)); elseif (g <= 2.0) tmp = Float64(cbrt(Float64(-g)) + t_0); else tmp = Float64(cbrt(-2.0) + t_0); 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[g, -1.55e+15], N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 2.0], N[(N[Power[(-g), 1/3], $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[Power[-2.0, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\mathbf{if}\;g \leq -1.55 \cdot 10^{+15}:\\
\;\;\;\;\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-2}\\
\mathbf{elif}\;g \leq 2:\\
\;\;\;\;\sqrt[3]{-g} + t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-2} + t_0\\
\end{array}
\end{array}
if g < -1.55e15Initial program 33.5%
Simplified33.5%
Taylor expanded in g around -inf 33.7%
*-commutative33.7%
Simplified33.7%
Taylor expanded in g around inf 15.3%
add-sqr-sqrt7.4%
sqrt-unprod9.4%
*-commutative9.4%
*-commutative9.4%
swap-sqr9.2%
*-commutative9.2%
*-commutative9.2%
swap-sqr9.2%
metadata-eval9.2%
metadata-eval9.2%
swap-sqr9.2%
count-29.2%
count-29.2%
frac-times9.2%
metadata-eval9.2%
metadata-eval9.2%
frac-times9.2%
swap-sqr9.4%
sqrt-unprod7.4%
add-sqr-sqrt15.3%
expm1-log1p-u8.9%
Applied egg-rr0.0%
Simplified56.9%
Taylor expanded in g around 0 56.9%
associate-*r/56.9%
mul-1-neg56.9%
Simplified56.9%
if -1.55e15 < g < 2Initial program 76.2%
Simplified76.2%
Taylor expanded in g around -inf 39.0%
*-commutative39.0%
Simplified39.0%
Taylor expanded in g around inf 16.5%
Taylor expanded in a around 0 16.5%
Simplified41.5%
if 2 < g Initial program 38.1%
Simplified38.1%
Taylor expanded in g around -inf 9.5%
*-commutative9.5%
Simplified9.5%
Taylor expanded in g around inf 14.3%
add-sqr-sqrt5.2%
sqrt-unprod10.8%
*-commutative10.8%
*-commutative10.8%
swap-sqr14.7%
*-commutative14.7%
*-commutative14.7%
swap-sqr14.7%
metadata-eval14.7%
metadata-eval14.7%
swap-sqr14.7%
count-214.7%
count-214.7%
frac-times14.7%
metadata-eval14.7%
metadata-eval14.7%
frac-times14.7%
swap-sqr10.8%
sqrt-unprod5.2%
add-sqr-sqrt14.3%
expm1-log1p-u8.1%
Applied egg-rr0.0%
Simplified45.6%
Final simplification48.7%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (<= g -0.108)
(+ (cbrt (/ (- g) a)) (cbrt -2.0))
(if (<= g 0.036) (+ (cbrt g) t_0) (+ (cbrt -2.0) t_0)))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (g <= -0.108) {
tmp = cbrt((-g / a)) + cbrt(-2.0);
} else if (g <= 0.036) {
tmp = cbrt(g) + t_0;
} else {
tmp = cbrt(-2.0) + t_0;
}
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 (g <= -0.108) {
tmp = Math.cbrt((-g / a)) + Math.cbrt(-2.0);
} else if (g <= 0.036) {
tmp = Math.cbrt(g) + t_0;
} else {
tmp = Math.cbrt(-2.0) + t_0;
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if (g <= -0.108) tmp = Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(-2.0)); elseif (g <= 0.036) tmp = Float64(cbrt(g) + t_0); else tmp = Float64(cbrt(-2.0) + t_0); 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[g, -0.108], N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 0.036], N[(N[Power[g, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[Power[-2.0, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\mathbf{if}\;g \leq -0.108:\\
\;\;\;\;\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-2}\\
\mathbf{elif}\;g \leq 0.036:\\
\;\;\;\;\sqrt[3]{g} + t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-2} + t_0\\
\end{array}
\end{array}
if g < -0.107999999999999999Initial program 34.6%
Simplified34.6%
Taylor expanded in g around -inf 34.7%
*-commutative34.7%
Simplified34.7%
Taylor expanded in g around inf 15.4%
add-sqr-sqrt7.7%
sqrt-unprod10.5%
*-commutative10.5%
*-commutative10.5%
swap-sqr10.3%
*-commutative10.3%
*-commutative10.3%
swap-sqr10.3%
metadata-eval10.3%
metadata-eval10.3%
swap-sqr10.3%
count-210.3%
count-210.3%
frac-times10.3%
metadata-eval10.3%
metadata-eval10.3%
frac-times10.3%
swap-sqr10.5%
sqrt-unprod7.7%
add-sqr-sqrt15.4%
expm1-log1p-u9.1%
Applied egg-rr0.0%
Simplified56.2%
Taylor expanded in g around 0 56.2%
associate-*r/56.2%
mul-1-neg56.2%
Simplified56.2%
if -0.107999999999999999 < g < 0.0359999999999999973Initial program 76.0%
Simplified76.0%
Taylor expanded in g around -inf 37.5%
*-commutative37.5%
Simplified37.5%
Taylor expanded in g around inf 16.4%
associate-*l/16.4%
clear-num18.5%
*-commutative18.5%
associate-*r*18.5%
metadata-eval18.5%
neg-mul-118.5%
Applied egg-rr18.5%
Simplified42.1%
if 0.0359999999999999973 < g Initial program 38.1%
Simplified38.1%
Taylor expanded in g around -inf 9.5%
*-commutative9.5%
Simplified9.5%
Taylor expanded in g around inf 14.3%
add-sqr-sqrt5.2%
sqrt-unprod10.8%
*-commutative10.8%
*-commutative10.8%
swap-sqr14.7%
*-commutative14.7%
*-commutative14.7%
swap-sqr14.7%
metadata-eval14.7%
metadata-eval14.7%
swap-sqr14.7%
count-214.7%
count-214.7%
frac-times14.7%
metadata-eval14.7%
metadata-eval14.7%
frac-times14.7%
swap-sqr10.8%
sqrt-unprod5.2%
add-sqr-sqrt14.3%
expm1-log1p-u8.1%
Applied egg-rr0.0%
Simplified45.6%
Final simplification48.7%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around -inf 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in g around -inf 72.9%
neg-mul-172.9%
Simplified72.9%
associate-*l/72.9%
*-commutative72.9%
associate-*r*72.9%
metadata-eval72.9%
neg-mul-172.9%
Applied egg-rr72.9%
Final simplification72.9%
(FPCore (g h a) :precision binary64 (+ (cbrt (/ (- g) a)) (cbrt -2.0)))
double code(double g, double h, double a) {
return cbrt((-g / a)) + cbrt(-2.0);
}
public static double code(double g, double h, double a) {
return Math.cbrt((-g / a)) + Math.cbrt(-2.0);
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(-2.0)) end
code[g_, h_, a_] := N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-2}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around -inf 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in g around inf 15.2%
add-sqr-sqrt6.9%
sqrt-unprod14.9%
*-commutative14.9%
*-commutative14.9%
swap-sqr16.3%
*-commutative16.3%
*-commutative16.3%
swap-sqr16.3%
metadata-eval16.3%
metadata-eval16.3%
swap-sqr16.3%
count-216.3%
count-216.3%
frac-times16.3%
metadata-eval16.3%
metadata-eval16.3%
frac-times16.3%
swap-sqr14.9%
sqrt-unprod6.9%
add-sqr-sqrt15.2%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified45.5%
Taylor expanded in g around 0 45.5%
associate-*r/45.5%
mul-1-neg45.5%
Simplified45.5%
Final simplification45.5%
(FPCore (g h a) :precision binary64 (+ (cbrt -2.0) (/ -2.0 (cbrt a))))
double code(double g, double h, double a) {
return cbrt(-2.0) + (-2.0 / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-2.0) + (-2.0 / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(-2.0) + Float64(-2.0 / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[-2.0, 1/3], $MachinePrecision] + N[(-2.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-2} + \frac{-2}{\sqrt[3]{a}}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around -inf 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in g around inf 15.2%
add-sqr-sqrt6.9%
sqrt-unprod14.9%
*-commutative14.9%
*-commutative14.9%
swap-sqr16.3%
*-commutative16.3%
*-commutative16.3%
swap-sqr16.3%
metadata-eval16.3%
metadata-eval16.3%
swap-sqr16.3%
count-216.3%
count-216.3%
frac-times16.3%
metadata-eval16.3%
metadata-eval16.3%
frac-times16.3%
swap-sqr14.9%
sqrt-unprod6.9%
add-sqr-sqrt15.2%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified45.5%
expm1-log1p-u20.0%
expm1-udef20.0%
Applied egg-rr0.0%
Simplified5.1%
Final simplification5.1%
(FPCore (g h a) :precision binary64 (cbrt -2.0))
double code(double g, double h, double a) {
return cbrt(-2.0);
}
public static double code(double g, double h, double a) {
return Math.cbrt(-2.0);
}
function code(g, h, a) return cbrt(-2.0) end
code[g_, h_, a_] := N[Power[-2.0, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-2}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around -inf 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in g around inf 15.2%
add-sqr-sqrt6.9%
sqrt-unprod14.9%
*-commutative14.9%
*-commutative14.9%
swap-sqr16.3%
*-commutative16.3%
*-commutative16.3%
swap-sqr16.3%
metadata-eval16.3%
metadata-eval16.3%
swap-sqr16.3%
count-216.3%
count-216.3%
frac-times16.3%
metadata-eval16.3%
metadata-eval16.3%
frac-times16.3%
swap-sqr14.9%
sqrt-unprod6.9%
add-sqr-sqrt15.2%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified45.5%
Taylor expanded in g around 0 4.8%
Final simplification4.8%
herbie shell --seed 2023319
(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))))))))