
(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 11 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 a)) (cbrt 0.0)))
double code(double g, double h, double a) {
return (cbrt(-g) / cbrt(a)) + cbrt(0.0);
}
public static double code(double g, double h, double a) {
return (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(0.0);
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(0.0)) end
code[g_, h_, a_] := N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[0.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{0}
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around inf 15.6%
associate-*l/15.6%
cbrt-div18.9%
*-commutative18.9%
associate-*r*18.9%
metadata-eval18.9%
neg-mul-118.9%
Applied egg-rr18.9%
Applied egg-rr96.4%
Final simplification96.4%
(FPCore (g h a) :precision binary64 (if (or (<= a -1.16e-18) (not (<= a 2.3e-43))) (+ (cbrt (* (/ 0.5 a) (* g -2.0))) (/ -1.0 (cbrt a))) (+ (cbrt (* g a)) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
double tmp;
if ((a <= -1.16e-18) || !(a <= 2.3e-43)) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + (-1.0 / cbrt(a));
} else {
tmp = cbrt((g * a)) + cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((a <= -1.16e-18) || !(a <= 2.3e-43)) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + (-1.0 / Math.cbrt(a));
} else {
tmp = Math.cbrt((g * a)) + Math.cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if ((a <= -1.16e-18) || !(a <= 2.3e-43)) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + Float64(-1.0 / cbrt(a))); else tmp = Float64(cbrt(Float64(g * a)) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); end return tmp end
code[g_, h_, a_] := If[Or[LessEqual[a, -1.16e-18], N[Not[LessEqual[a, 2.3e-43]], $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[N[(g * a), $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}
\mathbf{if}\;a \leq -1.16 \cdot 10^{-18} \lor \neg \left(a \leq 2.3 \cdot 10^{-43}\right):\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \frac{-1}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g \cdot a} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\end{array}
\end{array}
if a < -1.16e-18 or 2.2999999999999999e-43 < a Initial program 45.0%
Simplified45.0%
Taylor expanded in g around -inf 23.4%
*-commutative23.4%
Simplified23.4%
Taylor expanded in g around inf 17.7%
*-un-lft-identity17.7%
*-commutative17.7%
Applied egg-rr0.0%
Simplified70.5%
if -1.16e-18 < a < 2.2999999999999999e-43Initial program 39.5%
Simplified39.5%
Taylor expanded in g around -inf 29.7%
*-commutative29.7%
Simplified29.7%
Taylor expanded in g around inf 12.8%
associate-*l/12.8%
cbrt-div12.8%
*-commutative12.8%
associate-*r*12.8%
metadata-eval12.8%
neg-mul-112.8%
Applied egg-rr12.8%
Applied egg-rr57.4%
unpow257.4%
rem-3cbrt-rft57.4%
Simplified57.4%
Final simplification65.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (<= a -4.3e-17)
(+ t_0 (cbrt -1.0))
(if (<= a 2.3e-20)
(+ (cbrt (* g a)) t_0)
(+ (cbrt -1.0) (cbrt (/ g (- a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (a <= -4.3e-17) {
tmp = t_0 + cbrt(-1.0);
} else if (a <= 2.3e-20) {
tmp = cbrt((g * a)) + t_0;
} else {
tmp = cbrt(-1.0) + cbrt((g / -a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (a <= -4.3e-17) {
tmp = t_0 + Math.cbrt(-1.0);
} else if (a <= 2.3e-20) {
tmp = Math.cbrt((g * a)) + t_0;
} else {
tmp = Math.cbrt(-1.0) + Math.cbrt((g / -a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if (a <= -4.3e-17) tmp = Float64(t_0 + cbrt(-1.0)); elseif (a <= 2.3e-20) tmp = Float64(cbrt(Float64(g * a)) + t_0); else tmp = Float64(cbrt(-1.0) + cbrt(Float64(g / Float64(-a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a, -4.3e-17], N[(t$95$0 + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.3e-20], N[(N[Power[N[(g * a), $MachinePrecision], 1/3], $MachinePrecision] + t$95$0), $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}
t_0 := \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\mathbf{if}\;a \leq -4.3 \cdot 10^{-17}:\\
\;\;\;\;t\_0 + \sqrt[3]{-1}\\
\mathbf{elif}\;a \leq 2.3 \cdot 10^{-20}:\\
\;\;\;\;\sqrt[3]{g \cdot a} + t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-1} + \sqrt[3]{\frac{g}{-a}}\\
\end{array}
\end{array}
if a < -4.30000000000000023e-17Initial program 39.4%
Simplified39.4%
Taylor expanded in g around -inf 19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in g around inf 17.4%
add-sqr-sqrt11.0%
sqrt-unprod24.3%
*-commutative24.3%
*-commutative24.3%
swap-sqr30.5%
*-commutative30.5%
*-commutative30.5%
swap-sqr30.5%
metadata-eval30.5%
metadata-eval30.5%
swap-sqr30.5%
count-230.5%
count-230.5%
frac-times30.5%
metadata-eval30.5%
metadata-eval30.5%
frac-times30.5%
swap-sqr24.3%
sqrt-unprod11.0%
add-sqr-sqrt17.4%
expm1-log1p-u14.6%
Applied egg-rr0.0%
Simplified41.0%
if -4.30000000000000023e-17 < a < 2.2999999999999999e-20Initial program 38.8%
Simplified38.8%
Taylor expanded in g around -inf 28.9%
*-commutative28.9%
Simplified28.9%
Taylor expanded in g around inf 12.9%
associate-*l/12.9%
cbrt-div12.9%
*-commutative12.9%
associate-*r*12.9%
metadata-eval12.9%
neg-mul-112.9%
Applied egg-rr12.9%
Applied egg-rr58.3%
unpow258.3%
rem-3cbrt-rft58.3%
Simplified58.3%
if 2.2999999999999999e-20 < a Initial program 50.9%
Simplified50.9%
Taylor expanded in g around -inf 26.8%
*-commutative26.8%
Simplified26.8%
Taylor expanded in g around inf 18.2%
add-sqr-sqrt8.1%
sqrt-unprod27.7%
*-commutative27.7%
*-commutative27.7%
swap-sqr32.1%
*-commutative32.1%
*-commutative32.1%
swap-sqr32.1%
metadata-eval32.1%
metadata-eval32.1%
swap-sqr32.1%
count-232.1%
count-232.1%
frac-times32.1%
metadata-eval32.1%
metadata-eval32.1%
frac-times32.1%
swap-sqr27.7%
sqrt-unprod8.1%
add-sqr-sqrt18.2%
expm1-log1p-u13.8%
Applied egg-rr0.0%
Simplified44.5%
Taylor expanded in g around 0 44.5%
mul-1-neg44.5%
distribute-neg-frac244.5%
Simplified44.5%
Final simplification49.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (<= g -30000.0)
(+ t_0 (cbrt -1.0))
(if (<= g 1.1e-49) (+ t_0 (cbrt g)) (+ (cbrt -1.0) (cbrt (/ g (- a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (g <= -30000.0) {
tmp = t_0 + cbrt(-1.0);
} else if (g <= 1.1e-49) {
tmp = t_0 + cbrt(g);
} else {
tmp = cbrt(-1.0) + cbrt((g / -a));
}
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 <= -30000.0) {
tmp = t_0 + Math.cbrt(-1.0);
} else if (g <= 1.1e-49) {
tmp = t_0 + Math.cbrt(g);
} else {
tmp = Math.cbrt(-1.0) + Math.cbrt((g / -a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if (g <= -30000.0) tmp = Float64(t_0 + cbrt(-1.0)); elseif (g <= 1.1e-49) tmp = Float64(t_0 + cbrt(g)); else tmp = Float64(cbrt(-1.0) + cbrt(Float64(g / Float64(-a)))); 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, -30000.0], N[(t$95$0 + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.1e-49], N[(t$95$0 + 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}
t_0 := \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\mathbf{if}\;g \leq -30000:\\
\;\;\;\;t\_0 + \sqrt[3]{-1}\\
\mathbf{elif}\;g \leq 1.1 \cdot 10^{-49}:\\
\;\;\;\;t\_0 + \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-1} + \sqrt[3]{\frac{g}{-a}}\\
\end{array}
\end{array}
if g < -3e4Initial program 33.8%
Simplified33.8%
Taylor expanded in g around -inf 34.0%
*-commutative34.0%
Simplified34.0%
Taylor expanded in g around inf 15.5%
add-sqr-sqrt9.2%
sqrt-unprod10.1%
*-commutative10.1%
*-commutative10.1%
swap-sqr15.6%
*-commutative15.6%
*-commutative15.6%
swap-sqr15.6%
metadata-eval15.6%
metadata-eval15.6%
swap-sqr15.6%
count-215.6%
count-215.6%
frac-times15.6%
metadata-eval15.6%
metadata-eval15.6%
frac-times15.6%
swap-sqr10.1%
sqrt-unprod9.2%
add-sqr-sqrt15.5%
expm1-log1p-u11.4%
Applied egg-rr0.0%
Simplified52.9%
if -3e4 < g < 1.09999999999999995e-49Initial program 67.6%
Simplified67.6%
Taylor expanded in g around -inf 48.8%
*-commutative48.8%
Simplified48.8%
Taylor expanded in g around inf 16.5%
Taylor expanded in a around 0 16.5%
Simplified49.1%
if 1.09999999999999995e-49 < g Initial program 37.2%
Simplified37.2%
Taylor expanded in g around -inf 9.3%
*-commutative9.3%
Simplified9.3%
Taylor expanded in g around inf 15.3%
add-sqr-sqrt6.5%
sqrt-unprod15.1%
*-commutative15.1%
*-commutative15.1%
swap-sqr17.5%
*-commutative17.5%
*-commutative17.5%
swap-sqr17.5%
metadata-eval17.5%
metadata-eval17.5%
swap-sqr17.5%
count-217.5%
count-217.5%
frac-times17.6%
metadata-eval17.6%
metadata-eval17.6%
frac-times17.5%
swap-sqr15.1%
sqrt-unprod6.5%
add-sqr-sqrt15.3%
expm1-log1p-u9.6%
Applied egg-rr0.0%
Simplified47.3%
Taylor expanded in g around 0 47.3%
mul-1-neg47.3%
distribute-neg-frac247.3%
Simplified47.3%
Final simplification49.5%
(FPCore (g h a)
:precision binary64
(if (<= g -550000000.0)
(+ (cbrt (* (/ -0.5 a) (+ g g))) (cbrt -1.0))
(if (<= g 7e-7)
(- (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 <= -550000000.0) {
tmp = cbrt(((-0.5 / a) * (g + g))) + cbrt(-1.0);
} else if (g <= 7e-7) {
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 <= -550000000.0) {
tmp = Math.cbrt(((-0.5 / a) * (g + g))) + Math.cbrt(-1.0);
} else if (g <= 7e-7) {
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 <= -550000000.0) tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) + cbrt(-1.0)); elseif (g <= 7e-7) 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, -550000000.0], N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 7e-7], 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 -550000000:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{-1}\\
\mathbf{elif}\;g \leq 7 \cdot 10^{-7}:\\
\;\;\;\;\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 < -5.5e8Initial program 32.0%
Simplified32.0%
Taylor expanded in g around -inf 32.2%
*-commutative32.2%
Simplified32.2%
Taylor expanded in g around inf 15.4%
add-sqr-sqrt9.3%
sqrt-unprod10.2%
*-commutative10.2%
*-commutative10.2%
swap-sqr15.9%
*-commutative15.9%
*-commutative15.9%
swap-sqr15.9%
metadata-eval15.9%
metadata-eval15.9%
swap-sqr15.9%
count-215.9%
count-215.9%
frac-times15.9%
metadata-eval15.9%
metadata-eval15.9%
frac-times15.9%
swap-sqr10.2%
sqrt-unprod9.3%
add-sqr-sqrt15.4%
expm1-log1p-u11.6%
Applied egg-rr0.0%
Simplified52.4%
if -5.5e8 < g < 6.99999999999999968e-7Initial program 72.7%
Simplified72.7%
Taylor expanded in g around -inf 45.5%
*-commutative45.5%
Simplified45.5%
Taylor expanded in g around inf 16.9%
Taylor expanded in g around 0 16.9%
Simplified48.0%
if 6.99999999999999968e-7 < g Initial program 31.0%
Simplified31.0%
Taylor expanded in g around -inf 8.3%
*-commutative8.3%
Simplified8.3%
Taylor expanded in g around inf 15.0%
add-sqr-sqrt6.9%
sqrt-unprod10.8%
*-commutative10.8%
*-commutative10.8%
swap-sqr13.4%
*-commutative13.4%
*-commutative13.4%
swap-sqr13.4%
metadata-eval13.4%
metadata-eval13.4%
swap-sqr13.4%
count-213.4%
count-213.4%
frac-times13.5%
metadata-eval13.5%
metadata-eval13.5%
frac-times13.4%
swap-sqr10.8%
sqrt-unprod6.9%
add-sqr-sqrt15.0%
expm1-log1p-u9.4%
Applied egg-rr0.0%
Simplified48.7%
Taylor expanded in g around 0 48.7%
mul-1-neg48.7%
distribute-neg-frac248.7%
Simplified48.7%
Final simplification49.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(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 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around -inf 75.9%
neg-mul-175.9%
Simplified75.9%
Taylor expanded in g around -inf 75.9%
mul-1-neg75.9%
Simplified75.9%
Final simplification75.9%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ -0.5 a) (+ g g))) (cbrt -1.0)))
double code(double g, double h, double a) {
return cbrt(((-0.5 / a) * (g + g))) + cbrt(-1.0);
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-0.5 / a) * (g + g))) + Math.cbrt(-1.0);
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) + cbrt(-1.0)) end
code[g_, h_, a_] := N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{-1}
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr20.2%
*-commutative20.2%
*-commutative20.2%
swap-sqr20.2%
metadata-eval20.2%
metadata-eval20.2%
swap-sqr20.2%
count-220.2%
count-220.2%
frac-times20.3%
metadata-eval20.3%
metadata-eval20.3%
frac-times20.2%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.6%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.2%
Final simplification46.2%
(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 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr20.2%
*-commutative20.2%
*-commutative20.2%
swap-sqr20.2%
metadata-eval20.2%
metadata-eval20.2%
swap-sqr20.2%
count-220.2%
count-220.2%
frac-times20.3%
metadata-eval20.3%
metadata-eval20.3%
frac-times20.2%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.6%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.2%
Taylor expanded in g around 0 46.2%
mul-1-neg46.2%
distribute-neg-frac246.2%
Simplified46.2%
Final simplification46.2%
(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 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr20.2%
*-commutative20.2%
*-commutative20.2%
swap-sqr20.2%
metadata-eval20.2%
metadata-eval20.2%
swap-sqr20.2%
count-220.2%
count-220.2%
frac-times20.3%
metadata-eval20.3%
metadata-eval20.3%
frac-times20.2%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.6%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.2%
Taylor expanded in g around 0 46.2%
Simplified5.1%
Final simplification5.1%
(FPCore (g h a) :precision binary64 -1.0)
double code(double g, double h, double a) {
return -1.0;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = -1.0d0
end function
public static double code(double g, double h, double a) {
return -1.0;
}
def code(g, h, a): return -1.0
function code(g, h, a) return -1.0 end
function tmp = code(g, h, a) tmp = -1.0; end
code[g_, h_, a_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr20.2%
*-commutative20.2%
*-commutative20.2%
swap-sqr20.2%
metadata-eval20.2%
metadata-eval20.2%
swap-sqr20.2%
count-220.2%
count-220.2%
frac-times20.3%
metadata-eval20.3%
metadata-eval20.3%
frac-times20.2%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.6%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.2%
Applied egg-rr4.3%
Final simplification4.3%
(FPCore (g h a) :precision binary64 1.0)
double code(double g, double h, double a) {
return 1.0;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = 1.0d0
end function
public static double code(double g, double h, double a) {
return 1.0;
}
def code(g, h, a): return 1.0
function code(g, h, a) return 1.0 end
function tmp = code(g, h, a) tmp = 1.0; end
code[g_, h_, a_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in g around inf 15.6%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr20.2%
*-commutative20.2%
*-commutative20.2%
swap-sqr20.2%
metadata-eval20.2%
metadata-eval20.2%
swap-sqr20.2%
count-220.2%
count-220.2%
frac-times20.3%
metadata-eval20.3%
metadata-eval20.3%
frac-times20.2%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.6%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.2%
Applied egg-rr4.6%
Final simplification4.6%
herbie shell --seed 2024071
(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))))))))