
(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 50.4%
Simplified50.4%
Taylor expanded in g around -inf 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in g around -inf 75.8%
neg-mul-175.8%
Simplified75.8%
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.6e-11)
(- t_0 (cbrt (/ g a)))
(if (<= a 1.32e-64)
(+ (/ (cbrt (- g)) (cbrt a)) (cbrt -1.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 <= -4.6e-11) {
tmp = t_0 - cbrt((g / a));
} else if (a <= 1.32e-64) {
tmp = (cbrt(-g) / cbrt(a)) + cbrt(-1.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 <= -4.6e-11) {
tmp = t_0 - Math.cbrt((g / a));
} else if (a <= 1.32e-64) {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-1.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 <= -4.6e-11) tmp = Float64(t_0 - cbrt(Float64(g / a))); elseif (a <= 1.32e-64) tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-1.0)); else tmp = Float64(t_0 + cbrt(Float64(-1.0 / Float64(a / 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.6e-11], N[(t$95$0 - N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.32e-64], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[-1.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 -4.6 \cdot 10^{-11}:\\
\;\;\;\;t\_0 - \sqrt[3]{\frac{g}{a}}\\
\mathbf{elif}\;a \leq 1.32 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-1}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \sqrt[3]{\frac{-1}{\frac{a}{g}}}\\
\end{array}
\end{array}
if a < -4.60000000000000027e-11Initial program 53.4%
Simplified53.4%
Taylor expanded in g around -inf 31.5%
*-commutative31.5%
Simplified31.5%
Taylor expanded in g around -inf 93.4%
neg-mul-193.4%
Simplified93.4%
Taylor expanded in g around -inf 93.4%
mul-1-neg93.4%
Simplified93.4%
if -4.60000000000000027e-11 < a < 1.32e-64Initial program 50.0%
Simplified50.0%
Taylor expanded in g around -inf 27.4%
*-commutative27.4%
Simplified27.4%
Taylor expanded in g around inf 12.7%
add-sqr-sqrt6.7%
sqrt-unprod4.5%
swap-sqr3.8%
frac-times3.8%
metadata-eval3.8%
metadata-eval3.8%
frac-times3.8%
*-commutative3.8%
*-commutative3.8%
swap-sqr3.8%
metadata-eval3.8%
metadata-eval3.8%
swap-sqr3.8%
count-23.8%
count-23.8%
swap-sqr4.5%
*-commutative4.5%
*-commutative4.5%
sqrt-unprod6.7%
add-sqr-sqrt12.7%
expm1-log1p-u6.8%
Applied egg-rr0.0%
Simplified53.4%
add-sqr-sqrt27.0%
sqrt-unprod12.0%
*-commutative12.0%
*-commutative12.0%
swap-sqr7.7%
frac-times7.7%
metadata-eval7.7%
metadata-eval7.7%
frac-times7.7%
count-27.7%
count-27.7%
swap-sqr7.7%
metadata-eval7.7%
metadata-eval7.7%
swap-sqr7.7%
*-commutative7.7%
*-commutative7.7%
swap-sqr12.0%
Applied egg-rr91.4%
if 1.32e-64 < a Initial program 48.4%
Simplified48.4%
Taylor expanded in g around -inf 30.5%
*-commutative30.5%
Simplified30.5%
Taylor expanded in g around -inf 86.7%
neg-mul-186.7%
Simplified86.7%
associate-*l/86.7%
clear-num86.7%
*-commutative86.7%
associate-*r*86.7%
metadata-eval86.7%
neg-mul-186.7%
Applied egg-rr86.7%
Final simplification90.6%
(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 50.4%
Simplified50.4%
Taylor expanded in g around -inf 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in g around -inf 75.8%
neg-mul-175.8%
Simplified75.8%
associate-*l/75.8%
cbrt-div95.5%
*-commutative95.5%
associate-*r*95.5%
metadata-eval95.5%
neg-mul-195.5%
Applied egg-rr95.5%
Final simplification95.5%
(FPCore (g h a) :precision binary64 (if (or (<= a -1.35e-40) (not (<= a 9e-10))) (+ (cbrt (* (/ 0.5 a) (* g -2.0))) (/ -1.0 (cbrt a))) (+ (cbrt g) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
double tmp;
if ((a <= -1.35e-40) || !(a <= 9e-10)) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + (-1.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.35e-40) || !(a <= 9e-10)) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + (-1.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.35e-40) || !(a <= 9e-10)) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + Float64(-1.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.35e-40], N[Not[LessEqual[a, 9e-10]], $MachinePrecision]], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-1.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.35 \cdot 10^{-40} \lor \neg \left(a \leq 9 \cdot 10^{-10}\right):\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \frac{-1}{\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.35e-40 or 8.9999999999999999e-10 < a Initial program 48.2%
Simplified48.2%
Taylor expanded in g around -inf 29.9%
*-commutative29.9%
Simplified29.9%
Taylor expanded in g around inf 17.7%
*-un-lft-identity46.1%
*-commutative46.1%
Applied egg-rr0.0%
Simplified69.6%
if -1.35e-40 < a < 8.9999999999999999e-10Initial program 52.8%
Simplified52.8%
Taylor expanded in g around -inf 28.9%
*-commutative28.9%
Simplified28.9%
Taylor expanded in g around inf 13.4%
Taylor expanded in a around 0 13.4%
Simplified57.9%
Final simplification64.0%
(FPCore (g h a) :precision binary64 (if (or (<= g -4.1e-38) (not (<= g 6.5e+28))) (+ (cbrt -1.0) (cbrt (/ g (- a)))) (+ (cbrt g) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
double tmp;
if ((g <= -4.1e-38) || !(g <= 6.5e+28)) {
tmp = cbrt(-1.0) + cbrt((g / -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 <= -4.1e-38) || !(g <= 6.5e+28)) {
tmp = Math.cbrt(-1.0) + Math.cbrt((g / -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 <= -4.1e-38) || !(g <= 6.5e+28)) tmp = Float64(cbrt(-1.0) + cbrt(Float64(g / Float64(-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, -4.1e-38], N[Not[LessEqual[g, 6.5e+28]], $MachinePrecision]], N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $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 -4.1 \cdot 10^{-38} \lor \neg \left(g \leq 6.5 \cdot 10^{+28}\right):\\
\;\;\;\;\sqrt[3]{-1} + \sqrt[3]{\frac{g}{-a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\end{array}
\end{array}
if g < -4.0999999999999998e-38 or 6.5000000000000001e28 < g Initial program 41.4%
Simplified41.4%
Taylor expanded in g around -inf 28.7%
*-commutative28.7%
Simplified28.7%
Taylor expanded in g around inf 15.1%
add-sqr-sqrt7.5%
sqrt-unprod11.5%
swap-sqr12.3%
frac-times12.3%
metadata-eval12.3%
metadata-eval12.3%
frac-times12.3%
*-commutative12.3%
*-commutative12.3%
swap-sqr12.3%
metadata-eval12.3%
metadata-eval12.3%
swap-sqr12.3%
count-212.3%
count-212.3%
swap-sqr11.5%
*-commutative11.5%
*-commutative11.5%
sqrt-unprod7.5%
add-sqr-sqrt15.1%
expm1-log1p-u9.3%
Applied egg-rr0.0%
Simplified53.7%
Taylor expanded in g around 0 53.7%
neg-mul-153.7%
distribute-neg-frac253.7%
Simplified53.7%
if -4.0999999999999998e-38 < g < 6.5000000000000001e28Initial program 73.8%
Simplified73.8%
Taylor expanded in g around -inf 31.2%
*-commutative31.2%
Simplified31.2%
Taylor expanded in g around inf 17.0%
Taylor expanded in a around 0 17.0%
Simplified48.6%
Final simplification52.3%
(FPCore (g h a)
:precision binary64
(if (<= g -2.8e-13)
(+ (cbrt -1.0) (cbrt (* (/ -0.5 a) (+ g g))))
(if (<= g 115000000000.0)
(- (cbrt (* (/ 0.5 a) (* g -2.0))) (cbrt g))
(+ (cbrt -1.0) (cbrt (/ g (- a)))))))
double code(double g, double h, double a) {
double tmp;
if (g <= -2.8e-13) {
tmp = cbrt(-1.0) + cbrt(((-0.5 / a) * (g + g)));
} else if (g <= 115000000000.0) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) - cbrt(g);
} else {
tmp = cbrt(-1.0) + cbrt((g / -a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= -2.8e-13) {
tmp = Math.cbrt(-1.0) + Math.cbrt(((-0.5 / a) * (g + g)));
} else if (g <= 115000000000.0) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) - Math.cbrt(g);
} else {
tmp = Math.cbrt(-1.0) + Math.cbrt((g / -a));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= -2.8e-13) tmp = Float64(cbrt(-1.0) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); elseif (g <= 115000000000.0) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) - cbrt(g)); else tmp = Float64(cbrt(-1.0) + cbrt(Float64(g / Float64(-a)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, -2.8e-13], N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 115000000000.0], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq -2.8 \cdot 10^{-13}:\\
\;\;\;\;\sqrt[3]{-1} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\mathbf{elif}\;g \leq 115000000000:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} - \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-1} + \sqrt[3]{\frac{g}{-a}}\\
\end{array}
\end{array}
if g < -2.8000000000000002e-13Initial program 45.3%
Simplified45.3%
Taylor expanded in g around -inf 45.5%
*-commutative45.5%
Simplified45.5%
Taylor expanded in g around inf 16.3%
add-sqr-sqrt7.7%
sqrt-unprod9.6%
swap-sqr10.4%
frac-times10.5%
metadata-eval10.5%
metadata-eval10.5%
frac-times10.4%
*-commutative10.4%
*-commutative10.4%
swap-sqr10.4%
metadata-eval10.4%
metadata-eval10.4%
swap-sqr10.4%
count-210.4%
count-210.4%
swap-sqr9.6%
*-commutative9.6%
*-commutative9.6%
sqrt-unprod7.7%
add-sqr-sqrt16.3%
expm1-log1p-u10.0%
Applied egg-rr0.0%
Simplified58.0%
if -2.8000000000000002e-13 < g < 1.15e11Initial program 73.9%
Simplified73.9%
Taylor expanded in g around -inf 35.8%
*-commutative35.8%
Simplified35.8%
Taylor expanded in g around inf 17.0%
Taylor expanded in g around 0 17.0%
Simplified50.1%
if 1.15e11 < g Initial program 37.0%
Simplified37.0%
Taylor expanded in g around -inf 9.2%
*-commutative9.2%
Simplified9.2%
Taylor expanded in g around inf 13.9%
add-sqr-sqrt7.6%
sqrt-unprod12.2%
swap-sqr13.0%
frac-times13.0%
metadata-eval13.0%
metadata-eval13.0%
frac-times13.0%
*-commutative13.0%
*-commutative13.0%
swap-sqr13.0%
metadata-eval13.0%
metadata-eval13.0%
swap-sqr13.0%
count-213.0%
count-213.0%
swap-sqr12.2%
*-commutative12.2%
*-commutative12.2%
sqrt-unprod7.6%
add-sqr-sqrt13.9%
expm1-log1p-u8.8%
Applied egg-rr0.0%
Simplified48.6%
Taylor expanded in g around 0 48.6%
neg-mul-148.6%
distribute-neg-frac248.6%
Simplified48.6%
Final simplification52.3%
(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(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 50.4%
Simplified50.4%
Taylor expanded in g around -inf 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in g around -inf 75.8%
neg-mul-175.8%
Simplified75.8%
Taylor expanded in g around -inf 75.8%
mul-1-neg75.8%
Simplified75.8%
Final simplification75.8%
(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 / Float64(-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} + \sqrt[3]{\frac{g}{-a}}
\end{array}
Initial program 50.4%
Simplified50.4%
Taylor expanded in g around -inf 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt8.1%
sqrt-unprod17.4%
swap-sqr18.4%
frac-times18.4%
metadata-eval18.4%
metadata-eval18.4%
frac-times18.4%
*-commutative18.4%
*-commutative18.4%
swap-sqr18.4%
metadata-eval18.4%
metadata-eval18.4%
swap-sqr18.4%
count-218.4%
count-218.4%
swap-sqr17.4%
*-commutative17.4%
*-commutative17.4%
sqrt-unprod8.1%
add-sqr-sqrt15.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified48.7%
Taylor expanded in g around 0 48.7%
neg-mul-148.7%
distribute-neg-frac248.7%
Simplified48.7%
Final simplification48.7%
(FPCore (g h a) :precision binary64 (+ (cbrt -1.0) (/ -1.0 (cbrt a))))
double code(double g, double h, double a) {
return cbrt(-1.0) + (-1.0 / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-1.0) + (-1.0 / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(-1.0) + Float64(-1.0 / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[(-1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-1} + \frac{-1}{\sqrt[3]{a}}
\end{array}
Initial program 50.4%
Simplified50.4%
Taylor expanded in g around -inf 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt8.1%
sqrt-unprod17.4%
swap-sqr18.4%
frac-times18.4%
metadata-eval18.4%
metadata-eval18.4%
frac-times18.4%
*-commutative18.4%
*-commutative18.4%
swap-sqr18.4%
metadata-eval18.4%
metadata-eval18.4%
swap-sqr18.4%
count-218.4%
count-218.4%
swap-sqr17.4%
*-commutative17.4%
*-commutative17.4%
sqrt-unprod8.1%
add-sqr-sqrt15.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified48.7%
*-un-lft-identity48.7%
*-commutative48.7%
Applied egg-rr0.0%
Simplified5.0%
Final simplification5.0%
(FPCore (g h a) :precision binary64 (- (cbrt -1.0) (cbrt g)))
double code(double g, double h, double a) {
return cbrt(-1.0) - cbrt(g);
}
public static double code(double g, double h, double a) {
return Math.cbrt(-1.0) - Math.cbrt(g);
}
function code(g, h, a) return Float64(cbrt(-1.0) - cbrt(g)) end
code[g_, h_, a_] := N[(N[Power[-1.0, 1/3], $MachinePrecision] - N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-1} - \sqrt[3]{g}
\end{array}
Initial program 50.4%
Simplified50.4%
Taylor expanded in g around -inf 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt8.1%
sqrt-unprod17.4%
swap-sqr18.4%
frac-times18.4%
metadata-eval18.4%
metadata-eval18.4%
frac-times18.4%
*-commutative18.4%
*-commutative18.4%
swap-sqr18.4%
metadata-eval18.4%
metadata-eval18.4%
swap-sqr18.4%
count-218.4%
count-218.4%
swap-sqr17.4%
*-commutative17.4%
*-commutative17.4%
sqrt-unprod8.1%
add-sqr-sqrt15.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified48.7%
Taylor expanded in g around 0 48.7%
Simplified4.5%
Final simplification4.5%
herbie shell --seed 2024051
(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))))))))