
(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)) (cbrt (* g -2.0))) (cbrt (* (- g g) (/ -0.5 a)))))
double code(double g, double h, double a) {
return (cbrt((0.5 / a)) * cbrt((g * -2.0))) + cbrt(((g - g) * (-0.5 / a)));
}
public static double code(double g, double h, double a) {
return (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + Math.cbrt(((g - g) * (-0.5 / a)));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))) end
code[g_, h_, a_] := 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[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}
\end{array}
Initial program 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around -inf 71.3%
neg-mul-171.3%
Simplified71.3%
cbrt-prod95.5%
Applied egg-rr95.5%
Final simplification95.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (- g g) (/ -0.5 a)))))
(if (<= a -4.3e-70)
(+ t_0 (cbrt (/ (- g) a)))
(if (<= a 4.8e-46)
(+ (/ (cbrt (- g)) (cbrt a)) (* -2.0 (cbrt g)))
(+ t_0 (cbrt (/ 1.0 (/ a (- g)))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -4.3e-70) {
tmp = t_0 + cbrt((-g / a));
} else if (a <= 4.8e-46) {
tmp = (cbrt(-g) / cbrt(a)) + (-2.0 * cbrt(g));
} else {
tmp = t_0 + cbrt((1.0 / (a / -g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -4.3e-70) {
tmp = t_0 + Math.cbrt((-g / a));
} else if (a <= 4.8e-46) {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + (-2.0 * Math.cbrt(g));
} else {
tmp = t_0 + Math.cbrt((1.0 / (a / -g)));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) tmp = 0.0 if (a <= -4.3e-70) tmp = Float64(t_0 + cbrt(Float64(Float64(-g) / a))); elseif (a <= 4.8e-46) tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + Float64(-2.0 * cbrt(g))); else tmp = Float64(t_0 + cbrt(Float64(1.0 / Float64(a / Float64(-g))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a, -4.3e-70], N[(t$95$0 + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4.8e-46], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[(1.0 / N[(a / (-g)), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\
\mathbf{if}\;a \leq -4.3 \cdot 10^{-70}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\
\mathbf{elif}\;a \leq 4.8 \cdot 10^{-46}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + -2 \cdot \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{1}{\frac{a}{-g}}}\\
\end{array}
\end{array}
if a < -4.3e-70Initial program 42.6%
Simplified42.6%
Taylor expanded in g around -inf 28.0%
*-commutative28.0%
Simplified28.0%
Taylor expanded in g around -inf 87.9%
neg-mul-187.9%
Simplified87.9%
associate-*l/88.0%
*-commutative88.0%
associate-*r*88.0%
metadata-eval88.0%
neg-mul-188.0%
Applied egg-rr88.0%
if -4.3e-70 < a < 4.80000000000000027e-46Initial program 33.2%
Simplified33.2%
Taylor expanded in g around -inf 18.7%
*-commutative18.7%
Simplified18.7%
Taylor expanded in g around inf 10.9%
associate-*l/10.9%
cbrt-div10.9%
*-commutative10.9%
associate-*r*10.9%
metadata-eval10.9%
neg-mul-110.9%
Applied egg-rr10.9%
add-sqr-sqrt5.6%
sqrt-unprod4.3%
swap-sqr4.3%
count-24.3%
count-24.3%
swap-sqr4.3%
metadata-eval4.3%
metadata-eval4.3%
swap-sqr4.3%
*-commutative4.3%
*-commutative4.3%
frac-times4.3%
metadata-eval4.3%
metadata-eval4.3%
frac-times4.3%
swap-sqr4.3%
*-commutative4.3%
*-commutative4.3%
Applied egg-rr10.9%
Simplified94.0%
if 4.80000000000000027e-46 < a Initial program 44.3%
Simplified44.3%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around -inf 94.2%
neg-mul-194.2%
Simplified94.2%
associate-*l/94.2%
clear-num94.3%
*-commutative94.3%
associate-*r*94.3%
metadata-eval94.3%
neg-mul-194.3%
Applied egg-rr94.3%
Final simplification91.9%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (/ (cbrt (- g)) (cbrt a))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + (cbrt(-g) / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + (Math.cbrt(-g) / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + Float64(cbrt(Float64(-g)) / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $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]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}}
\end{array}
Initial program 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around -inf 71.3%
neg-mul-171.3%
Simplified71.3%
associate-*l/15.1%
cbrt-div18.7%
*-commutative18.7%
associate-*r*18.7%
metadata-eval18.7%
neg-mul-118.7%
Applied egg-rr95.4%
Final simplification95.4%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (- g g) (/ -0.5 a)))))
(if (<= a -3.2e-70)
(+ t_0 (cbrt (/ (- g) a)))
(if (<= a 1.6e-50)
(+ (/ (cbrt (- g)) (cbrt a)) (cbrt -2.0))
(+ t_0 (cbrt (/ 1.0 (/ a (- g)))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -3.2e-70) {
tmp = t_0 + cbrt((-g / a));
} else if (a <= 1.6e-50) {
tmp = (cbrt(-g) / cbrt(a)) + cbrt(-2.0);
} else {
tmp = t_0 + cbrt((1.0 / (a / -g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -3.2e-70) {
tmp = t_0 + Math.cbrt((-g / a));
} else if (a <= 1.6e-50) {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-2.0);
} else {
tmp = t_0 + Math.cbrt((1.0 / (a / -g)));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) tmp = 0.0 if (a <= -3.2e-70) tmp = Float64(t_0 + cbrt(Float64(Float64(-g) / a))); elseif (a <= 1.6e-50) tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-2.0)); else tmp = Float64(t_0 + cbrt(Float64(1.0 / Float64(a / Float64(-g))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a, -3.2e-70], N[(t$95$0 + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.6e-50], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[(1.0 / N[(a / (-g)), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\
\mathbf{if}\;a \leq -3.2 \cdot 10^{-70}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-2}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{1}{\frac{a}{-g}}}\\
\end{array}
\end{array}
if a < -3.1999999999999997e-70Initial program 42.6%
Simplified42.6%
Taylor expanded in g around -inf 28.0%
*-commutative28.0%
Simplified28.0%
Taylor expanded in g around -inf 87.9%
neg-mul-187.9%
Simplified87.9%
associate-*l/88.0%
*-commutative88.0%
associate-*r*88.0%
metadata-eval88.0%
neg-mul-188.0%
Applied egg-rr88.0%
if -3.1999999999999997e-70 < a < 1.6e-50Initial program 33.2%
Simplified33.2%
Taylor expanded in g around -inf 18.7%
*-commutative18.7%
Simplified18.7%
Taylor expanded in g around inf 10.9%
add-sqr-sqrt5.6%
sqrt-unprod4.3%
*-commutative4.3%
*-commutative4.3%
swap-sqr4.2%
*-commutative4.2%
*-commutative4.2%
swap-sqr4.2%
metadata-eval4.2%
metadata-eval4.2%
swap-sqr4.2%
count-24.2%
count-24.2%
frac-times4.2%
metadata-eval4.2%
metadata-eval4.2%
frac-times4.2%
swap-sqr4.3%
sqrt-unprod5.6%
add-sqr-sqrt10.9%
expm1-log1p-u5.8%
Applied egg-rr0.0%
Simplified38.8%
add-sqr-sqrt20.1%
sqrt-unprod10.6%
swap-sqr6.0%
count-26.0%
count-26.0%
swap-sqr6.0%
metadata-eval6.0%
metadata-eval6.0%
swap-sqr6.0%
*-commutative6.0%
*-commutative6.0%
frac-times6.0%
metadata-eval6.0%
metadata-eval6.0%
frac-times6.0%
swap-sqr10.6%
*-commutative10.6%
*-commutative10.6%
sqrt-unprod20.1%
Applied egg-rr90.9%
if 1.6e-50 < a Initial program 44.3%
Simplified44.3%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around -inf 94.2%
neg-mul-194.2%
Simplified94.2%
associate-*l/94.2%
clear-num94.3%
*-commutative94.3%
associate-*r*94.3%
metadata-eval94.3%
neg-mul-194.3%
Applied egg-rr94.3%
Final simplification90.6%
(FPCore (g h a) :precision binary64 (if (or (<= g -1.42e+14) (not (<= g 1.6e+15))) (+ (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 ((g <= -1.42e+14) || !(g <= 1.6e+15)) {
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 ((g <= -1.42e+14) || !(g <= 1.6e+15)) {
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 ((g <= -1.42e+14) || !(g <= 1.6e+15)) 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[g, -1.42e+14], N[Not[LessEqual[g, 1.6e+15]], $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}\;g \leq -1.42 \cdot 10^{+14} \lor \neg \left(g \leq 1.6 \cdot 10^{+15}\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 g < -1.42e14 or 1.6e15 < g Initial program 30.9%
Simplified30.9%
Taylor expanded in g around -inf 19.2%
*-commutative19.2%
Simplified19.2%
Taylor expanded in g around inf 14.6%
expm1-log1p-u20.2%
expm1-udef20.2%
Applied egg-rr0.0%
Simplified67.9%
if -1.42e14 < g < 1.6e15Initial program 65.0%
Simplified65.0%
Taylor expanded in g around -inf 38.2%
*-commutative38.2%
Simplified38.2%
Taylor expanded in g around inf 16.5%
Taylor expanded in a around 0 16.5%
Simplified46.0%
Final simplification62.5%
(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 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around -inf 71.3%
neg-mul-171.3%
Simplified71.3%
associate-*l/71.4%
*-commutative71.4%
associate-*r*71.4%
metadata-eval71.4%
neg-mul-171.4%
Applied egg-rr71.4%
Final simplification71.4%
(FPCore (g h a) :precision binary64 (+ (cbrt -2.0) (cbrt (* (/ -0.5 a) (+ g g)))))
double code(double g, double h, double a) {
return cbrt(-2.0) + cbrt(((-0.5 / a) * (g + g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-2.0) + Math.cbrt(((-0.5 / a) * (g + g)));
}
function code(g, h, a) return Float64(cbrt(-2.0) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))) end
code[g_, h_, a_] := N[(N[Power[-2.0, 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]{-2} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}
\end{array}
Initial program 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around inf 15.1%
add-sqr-sqrt7.1%
sqrt-unprod12.6%
*-commutative12.6%
*-commutative12.6%
swap-sqr14.1%
*-commutative14.1%
*-commutative14.1%
swap-sqr14.1%
metadata-eval14.1%
metadata-eval14.1%
swap-sqr14.1%
count-214.1%
count-214.1%
frac-times14.8%
metadata-eval14.8%
metadata-eval14.8%
frac-times14.1%
swap-sqr12.6%
sqrt-unprod7.1%
add-sqr-sqrt15.1%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified43.0%
Final simplification43.0%
(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 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around inf 15.1%
add-sqr-sqrt7.1%
sqrt-unprod12.6%
*-commutative12.6%
*-commutative12.6%
swap-sqr14.1%
*-commutative14.1%
*-commutative14.1%
swap-sqr14.1%
metadata-eval14.1%
metadata-eval14.1%
swap-sqr14.1%
count-214.1%
count-214.1%
frac-times14.8%
metadata-eval14.8%
metadata-eval14.8%
frac-times14.1%
swap-sqr12.6%
sqrt-unprod7.1%
add-sqr-sqrt15.1%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified43.0%
Taylor expanded in g around 0 43.0%
associate-*r/43.0%
mul-1-neg43.0%
Simplified43.0%
Final simplification43.0%
(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 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around inf 15.1%
add-sqr-sqrt7.1%
sqrt-unprod12.6%
*-commutative12.6%
*-commutative12.6%
swap-sqr14.1%
*-commutative14.1%
*-commutative14.1%
swap-sqr14.1%
metadata-eval14.1%
metadata-eval14.1%
swap-sqr14.1%
count-214.1%
count-214.1%
frac-times14.8%
metadata-eval14.8%
metadata-eval14.8%
frac-times14.1%
swap-sqr12.6%
sqrt-unprod7.1%
add-sqr-sqrt15.1%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified43.0%
expm1-log1p-u19.7%
expm1-udef19.7%
Applied egg-rr0.0%
Simplified4.9%
Final simplification4.9%
(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 39.3%
Simplified39.3%
Taylor expanded in g around -inf 23.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in g around inf 15.1%
add-sqr-sqrt7.1%
sqrt-unprod12.6%
*-commutative12.6%
*-commutative12.6%
swap-sqr14.1%
*-commutative14.1%
*-commutative14.1%
swap-sqr14.1%
metadata-eval14.1%
metadata-eval14.1%
swap-sqr14.1%
count-214.1%
count-214.1%
frac-times14.8%
metadata-eval14.8%
metadata-eval14.8%
frac-times14.1%
swap-sqr12.6%
sqrt-unprod7.1%
add-sqr-sqrt15.1%
expm1-log1p-u9.8%
Applied egg-rr0.0%
Simplified43.0%
Taylor expanded in g around 0 4.6%
Final simplification4.6%
herbie shell --seed 2023310
(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))))))))