
(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 (/ 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 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around -inf 69.7%
neg-mul-169.7%
Simplified69.7%
cbrt-prod95.2%
Applied egg-rr95.2%
Final simplification95.2%
(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 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around -inf 69.7%
neg-mul-169.7%
Simplified69.7%
associate-*l/69.7%
cbrt-div95.2%
*-commutative95.2%
associate-*r*95.2%
metadata-eval95.2%
neg-mul-195.2%
Applied egg-rr95.2%
Final simplification95.2%
(FPCore (g h a) :precision binary64 (if (or (<= a -1.2e-67) (not (<= a 1.5e-30))) (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (* (/ 0.5 a) (* g -2.0)))) (+ (/ (cbrt (- g)) (cbrt a)) (cbrt -2.0))))
double code(double g, double h, double a) {
double tmp;
if ((a <= -1.2e-67) || !(a <= 1.5e-30)) {
tmp = cbrt(((g - g) * (-0.5 / a))) + cbrt(((0.5 / a) * (g * -2.0)));
} 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 <= -1.2e-67) || !(a <= 1.5e-30)) {
tmp = Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(((0.5 / a) * (g * -2.0)));
} else {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-2.0);
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if ((a <= -1.2e-67) || !(a <= 1.5e-30)) tmp = Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0)))); else tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-2.0)); end return tmp end
code[g_, h_, a_] := If[Or[LessEqual[a, -1.2e-67], N[Not[LessEqual[a, 1.5e-30]], $MachinePrecision]], N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $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 -1.2 \cdot 10^{-67} \lor \neg \left(a \leq 1.5 \cdot 10^{-30}\right):\\
\;\;\;\;\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-2}\\
\end{array}
\end{array}
if a < -1.2e-67 or 1.49999999999999995e-30 < a Initial program 46.7%
Simplified46.7%
Taylor expanded in g around -inf 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around -inf 85.6%
neg-mul-185.6%
Simplified85.6%
if -1.2e-67 < a < 1.49999999999999995e-30Initial program 39.2%
Simplified39.2%
Taylor expanded in g around -inf 25.4%
*-commutative25.4%
Simplified25.4%
Taylor expanded in g around inf 11.6%
add-sqr-sqrt5.6%
sqrt-unprod3.2%
swap-sqr3.7%
frac-times3.8%
metadata-eval3.8%
metadata-eval3.8%
frac-times3.7%
*-commutative3.7%
*-commutative3.7%
swap-sqr3.7%
metadata-eval3.7%
metadata-eval3.7%
swap-sqr3.7%
count-23.7%
count-23.7%
swap-sqr3.2%
*-commutative3.2%
*-commutative3.2%
sqrt-unprod5.6%
add-sqr-sqrt11.6%
expm1-log1p-u5.9%
Applied egg-rr0.0%
Simplified45.3%
add-sqr-sqrt22.5%
sqrt-unprod5.4%
*-commutative5.4%
*-commutative5.4%
swap-sqr4.6%
frac-times4.6%
metadata-eval4.6%
metadata-eval4.6%
frac-times4.6%
count-24.6%
count-24.6%
swap-sqr4.6%
metadata-eval4.6%
metadata-eval4.6%
swap-sqr4.6%
*-commutative4.6%
*-commutative4.6%
swap-sqr5.4%
sqrt-unprod22.5%
add-sqr-sqrt45.3%
Applied egg-rr91.3%
Final simplification88.2%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (or (<= a -1e-32) (not (<= a 4.2e-38)))
(+ (cbrt (/ -0.25 (* a g))) t_0)
(+ t_0 (cbrt g)))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if ((a <= -1e-32) || !(a <= 4.2e-38)) {
tmp = cbrt((-0.25 / (a * g))) + t_0;
} else {
tmp = t_0 + cbrt(g);
}
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 <= -1e-32) || !(a <= 4.2e-38)) {
tmp = Math.cbrt((-0.25 / (a * g))) + t_0;
} else {
tmp = t_0 + Math.cbrt(g);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if ((a <= -1e-32) || !(a <= 4.2e-38)) tmp = Float64(cbrt(Float64(-0.25 / Float64(a * g))) + t_0); else tmp = Float64(t_0 + cbrt(g)); 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[Or[LessEqual[a, -1e-32], N[Not[LessEqual[a, 4.2e-38]], $MachinePrecision]], N[(N[Power[N[(-0.25 / N[(a * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + t$95$0), $MachinePrecision], N[(t$95$0 + N[Power[g, 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 -1 \cdot 10^{-32} \lor \neg \left(a \leq 4.2 \cdot 10^{-38}\right):\\
\;\;\;\;\sqrt[3]{\frac{-0.25}{a \cdot g}} + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{g}\\
\end{array}
\end{array}
if a < -1.00000000000000006e-32 or 4.20000000000000026e-38 < a Initial program 44.9%
Simplified44.9%
Taylor expanded in g around -inf 25.9%
*-commutative25.9%
Simplified25.9%
Taylor expanded in g around inf 17.1%
Applied egg-rr69.0%
if -1.00000000000000006e-32 < a < 4.20000000000000026e-38Initial program 41.6%
Simplified41.6%
Taylor expanded in g around -inf 26.3%
*-commutative26.3%
Simplified26.3%
Taylor expanded in g around inf 12.1%
Taylor expanded in a around 0 12.1%
Simplified52.8%
Final simplification61.4%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (or (<= g -1.12e+23) (not (<= g 9.5e-5)))
(+ t_0 (cbrt (/ -2.0 a)))
(+ t_0 (cbrt g)))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if ((g <= -1.12e+23) || !(g <= 9.5e-5)) {
tmp = t_0 + cbrt((-2.0 / a));
} else {
tmp = t_0 + cbrt(g);
}
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.12e+23) || !(g <= 9.5e-5)) {
tmp = t_0 + Math.cbrt((-2.0 / a));
} else {
tmp = t_0 + Math.cbrt(g);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if ((g <= -1.12e+23) || !(g <= 9.5e-5)) tmp = Float64(t_0 + cbrt(Float64(-2.0 / a))); else tmp = Float64(t_0 + cbrt(g)); 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[Or[LessEqual[g, -1.12e+23], N[Not[LessEqual[g, 9.5e-5]], $MachinePrecision]], N[(t$95$0 + N[Power[N[(-2.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[g, 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 -1.12 \cdot 10^{+23} \lor \neg \left(g \leq 9.5 \cdot 10^{-5}\right):\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-2}{a}}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{g}\\
\end{array}
\end{array}
if g < -1.12e23 or 9.5000000000000005e-5 < g Initial program 35.4%
Simplified35.4%
Taylor expanded in g around -inf 20.8%
*-commutative20.8%
Simplified20.8%
Taylor expanded in g around inf 14.4%
add-sqr-sqrt7.0%
sqrt-unprod10.1%
swap-sqr14.6%
frac-times15.1%
metadata-eval15.1%
metadata-eval15.1%
frac-times14.6%
*-commutative14.6%
*-commutative14.6%
swap-sqr14.6%
metadata-eval14.6%
metadata-eval14.6%
swap-sqr14.6%
count-214.6%
count-214.6%
swap-sqr10.1%
*-commutative10.1%
*-commutative10.1%
sqrt-unprod7.0%
add-sqr-sqrt14.4%
associate-*r/14.4%
Applied egg-rr0.0%
Simplified35.3%
Taylor expanded in a around 0 66.1%
if -1.12e23 < g < 9.5000000000000005e-5Initial program 65.7%
Simplified65.7%
Taylor expanded in g around -inf 41.2%
*-commutative41.2%
Simplified41.2%
Taylor expanded in g around inf 15.7%
Taylor expanded in a around 0 15.7%
Simplified45.8%
Final simplification60.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (* (/ 0.5 a) (* g -2.0)))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + cbrt(((0.5 / a) * (g * -2.0)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(((0.5 / a) * (g * -2.0)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0)))) 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[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}
\end{array}
Initial program 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around -inf 69.7%
neg-mul-169.7%
Simplified69.7%
Final simplification69.7%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (<= g -55.0)
(+ t_0 (cbrt -0.5))
(if (<= g 1.45e+73)
(+ t_0 (cbrt g))
(+ (cbrt -2.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 <= -55.0) {
tmp = t_0 + cbrt(-0.5);
} else if (g <= 1.45e+73) {
tmp = t_0 + cbrt(g);
} else {
tmp = cbrt(-2.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 <= -55.0) {
tmp = t_0 + Math.cbrt(-0.5);
} else if (g <= 1.45e+73) {
tmp = t_0 + Math.cbrt(g);
} else {
tmp = Math.cbrt(-2.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 <= -55.0) tmp = Float64(t_0 + cbrt(-0.5)); elseif (g <= 1.45e+73) tmp = Float64(t_0 + cbrt(g)); else tmp = Float64(cbrt(-2.0) + cbrt(Float64(Float64(-g) / 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, -55.0], N[(t$95$0 + N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.45e+73], N[(t$95$0 + N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[-2.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 -55:\\
\;\;\;\;t_0 + \sqrt[3]{-0.5}\\
\mathbf{elif}\;g \leq 1.45 \cdot 10^{+73}:\\
\;\;\;\;t_0 + \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-2} + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if g < -55Initial program 38.2%
Simplified38.2%
Taylor expanded in g around -inf 38.4%
*-commutative38.4%
Simplified38.4%
Taylor expanded in g around inf 15.0%
Applied egg-rr0.0%
Simplified52.7%
if -55 < g < 1.4500000000000001e73Initial program 70.8%
Simplified70.8%
Taylor expanded in g around -inf 35.6%
*-commutative35.6%
Simplified35.6%
Taylor expanded in g around inf 16.3%
Taylor expanded in a around 0 16.3%
Simplified43.1%
if 1.4500000000000001e73 < g Initial program 25.5%
Simplified25.5%
Taylor expanded in g around -inf 7.3%
*-commutative7.3%
Simplified7.3%
Taylor expanded in g around inf 13.3%
add-sqr-sqrt6.0%
sqrt-unprod6.8%
swap-sqr8.7%
frac-times9.7%
metadata-eval9.7%
metadata-eval9.7%
frac-times8.7%
*-commutative8.7%
*-commutative8.7%
swap-sqr8.7%
metadata-eval8.7%
metadata-eval8.7%
swap-sqr8.7%
count-28.7%
count-28.7%
swap-sqr6.8%
*-commutative6.8%
*-commutative6.8%
sqrt-unprod6.0%
add-sqr-sqrt13.3%
expm1-log1p-u7.4%
Applied egg-rr0.0%
Simplified44.2%
Taylor expanded in g around 0 44.3%
Final simplification46.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 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around -inf 69.7%
neg-mul-169.7%
Simplified69.7%
associate-*l/69.7%
*-commutative69.7%
associate-*r*69.7%
metadata-eval69.7%
neg-mul-169.7%
Applied egg-rr69.7%
Final simplification69.7%
(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 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around inf 14.8%
add-sqr-sqrt7.3%
sqrt-unprod14.0%
swap-sqr17.9%
frac-times18.2%
metadata-eval18.2%
metadata-eval18.2%
frac-times17.9%
*-commutative17.9%
*-commutative17.9%
swap-sqr17.9%
metadata-eval17.9%
metadata-eval17.9%
swap-sqr17.9%
count-217.9%
count-217.9%
swap-sqr14.0%
*-commutative14.0%
*-commutative14.0%
sqrt-unprod7.3%
add-sqr-sqrt14.8%
expm1-log1p-u9.9%
Applied egg-rr0.0%
Simplified43.2%
Final simplification43.2%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ -0.5 a) (+ g g))) (cbrt -0.5)))
double code(double g, double h, double a) {
return cbrt(((-0.5 / a) * (g + g))) + cbrt(-0.5);
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-0.5 / a) * (g + g))) + Math.cbrt(-0.5);
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) + cbrt(-0.5)) end
code[g_, h_, a_] := N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{-0.5}
\end{array}
Initial program 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around inf 14.8%
Applied egg-rr0.0%
Simplified43.3%
Final simplification43.3%
(FPCore (g h a) :precision binary64 (if (<= a -9e-308) (+ (cbrt -2.0) (cbrt g)) (+ (cbrt -2.0) (* -2.0 (cbrt g)))))
double code(double g, double h, double a) {
double tmp;
if (a <= -9e-308) {
tmp = cbrt(-2.0) + cbrt(g);
} else {
tmp = cbrt(-2.0) + (-2.0 * cbrt(g));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (a <= -9e-308) {
tmp = Math.cbrt(-2.0) + Math.cbrt(g);
} else {
tmp = Math.cbrt(-2.0) + (-2.0 * Math.cbrt(g));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (a <= -9e-308) tmp = Float64(cbrt(-2.0) + cbrt(g)); else tmp = Float64(cbrt(-2.0) + Float64(-2.0 * cbrt(g))); end return tmp end
code[g_, h_, a_] := If[LessEqual[a, -9e-308], N[(N[Power[-2.0, 1/3], $MachinePrecision] + N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[-2.0, 1/3], $MachinePrecision] + N[(-2.0 * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-308}:\\
\;\;\;\;\sqrt[3]{-2} + \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-2} + -2 \cdot \sqrt[3]{g}\\
\end{array}
\end{array}
if a < -9.00000000000000017e-308Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.2%
*-commutative26.2%
Simplified26.2%
Taylor expanded in g around inf 14.9%
add-sqr-sqrt7.9%
sqrt-unprod17.0%
swap-sqr21.2%
frac-times21.2%
metadata-eval21.2%
metadata-eval21.2%
frac-times21.2%
*-commutative21.2%
*-commutative21.2%
swap-sqr21.2%
metadata-eval21.2%
metadata-eval21.2%
swap-sqr21.2%
count-221.2%
count-221.2%
swap-sqr17.0%
*-commutative17.0%
*-commutative17.0%
sqrt-unprod7.9%
add-sqr-sqrt14.9%
expm1-log1p-u11.0%
Applied egg-rr0.0%
Simplified38.7%
Taylor expanded in g around 0 38.7%
Simplified6.9%
if -9.00000000000000017e-308 < a Initial program 43.9%
Simplified43.9%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around inf 14.7%
add-sqr-sqrt6.7%
sqrt-unprod11.1%
swap-sqr14.9%
frac-times15.6%
metadata-eval15.6%
metadata-eval15.6%
frac-times14.9%
*-commutative14.9%
*-commutative14.9%
swap-sqr14.9%
metadata-eval14.9%
metadata-eval14.9%
swap-sqr14.9%
count-214.9%
count-214.9%
swap-sqr11.1%
*-commutative11.1%
*-commutative11.1%
sqrt-unprod6.7%
add-sqr-sqrt14.7%
expm1-log1p-u8.9%
Applied egg-rr0.0%
Simplified47.4%
add-sqr-sqrt22.3%
sqrt-unprod10.1%
*-commutative10.1%
*-commutative10.1%
swap-sqr6.9%
frac-times6.9%
metadata-eval6.9%
metadata-eval6.9%
frac-times6.9%
count-26.9%
count-26.9%
swap-sqr6.9%
metadata-eval6.9%
metadata-eval6.9%
swap-sqr6.9%
*-commutative6.9%
*-commutative6.9%
swap-sqr10.1%
sqrt-unprod22.3%
add-sqr-sqrt47.4%
Applied egg-rr46.8%
Simplified7.6%
Final simplification7.2%
(FPCore (g h a) :precision binary64 (+ (cbrt -2.0) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt(-2.0) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-2.0) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(-2.0) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[-2.0, 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-2} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around inf 14.8%
add-sqr-sqrt7.3%
sqrt-unprod14.0%
swap-sqr17.9%
frac-times18.2%
metadata-eval18.2%
metadata-eval18.2%
frac-times17.9%
*-commutative17.9%
*-commutative17.9%
swap-sqr17.9%
metadata-eval17.9%
metadata-eval17.9%
swap-sqr17.9%
count-217.9%
count-217.9%
swap-sqr14.0%
*-commutative14.0%
*-commutative14.0%
sqrt-unprod7.3%
add-sqr-sqrt14.8%
expm1-log1p-u9.9%
Applied egg-rr0.0%
Simplified43.2%
Taylor expanded in g around 0 43.2%
Final simplification43.2%
(FPCore (g h a) :precision binary64 -2.0)
double code(double g, double h, double a) {
return -2.0;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = -2.0d0
end function
public static double code(double g, double h, double a) {
return -2.0;
}
def code(g, h, a): return -2.0
function code(g, h, a) return -2.0 end
function tmp = code(g, h, a) tmp = -2.0; end
code[g_, h_, a_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 43.3%
Simplified43.3%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around inf 14.8%
add-sqr-sqrt7.3%
sqrt-unprod14.0%
swap-sqr17.9%
frac-times18.2%
metadata-eval18.2%
metadata-eval18.2%
frac-times17.9%
*-commutative17.9%
*-commutative17.9%
swap-sqr17.9%
metadata-eval17.9%
metadata-eval17.9%
swap-sqr17.9%
count-217.9%
count-217.9%
swap-sqr14.0%
*-commutative14.0%
*-commutative14.0%
sqrt-unprod7.3%
add-sqr-sqrt14.8%
expm1-log1p-u9.9%
Applied egg-rr0.0%
Simplified43.2%
Taylor expanded in g around 0 4.5%
Simplified4.5%
Final simplification4.5%
herbie shell --seed 2023331
(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))))))))