
(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 9 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.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around inf 15.9%
associate-*l/15.9%
cbrt-div17.6%
*-commutative17.6%
associate-*r*17.6%
metadata-eval17.6%
neg-mul-117.6%
Applied egg-rr17.6%
Applied egg-rr95.8%
Final simplification95.8%
(FPCore (g h a) :precision binary64 (if (or (<= a -3.9e-41) (not (<= a 8.5e-32))) (+ (cbrt (* (/ 0.5 a) (* g -2.0))) (/ -2.0 (cbrt a))) (+ (cbrt g) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
double tmp;
if ((a <= -3.9e-41) || !(a <= 8.5e-32)) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + (-2.0 / cbrt(a));
} else {
tmp = cbrt(g) + cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((a <= -3.9e-41) || !(a <= 8.5e-32)) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + (-2.0 / Math.cbrt(a));
} else {
tmp = Math.cbrt(g) + Math.cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if ((a <= -3.9e-41) || !(a <= 8.5e-32)) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + Float64(-2.0 / cbrt(a))); else tmp = Float64(cbrt(g) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); end return tmp end
code[g_, h_, a_] := If[Or[LessEqual[a, -3.9e-41], N[Not[LessEqual[a, 8.5e-32]], $MachinePrecision]], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-2.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.9 \cdot 10^{-41} \lor \neg \left(a \leq 8.5 \cdot 10^{-32}\right):\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \frac{-2}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\end{array}
\end{array}
if a < -3.89999999999999991e-41 or 8.5000000000000003e-32 < a Initial program 41.9%
Simplified41.9%
Taylor expanded in g around -inf 25.8%
*-commutative25.8%
Simplified25.8%
Taylor expanded in g around inf 18.2%
Applied egg-rr0.0%
Simplified73.2%
if -3.89999999999999991e-41 < a < 8.5000000000000003e-32Initial program 44.1%
Simplified44.1%
Taylor expanded in g around -inf 28.1%
*-commutative28.1%
Simplified28.1%
Taylor expanded in g around inf 12.6%
Taylor expanded in a around 0 12.6%
Simplified55.4%
Final simplification66.0%
(FPCore (g h a)
:precision binary64
(if (<= g -4.8e-5)
(+ (cbrt (/ (- g) a)) (cbrt -2.0))
(if (<= g 0.25)
(+ (cbrt (* (/ 0.5 a) (* g -2.0))) (* -2.0 (cbrt g)))
(+ (cbrt (* (/ -0.5 a) (+ g g))) (cbrt -2.0)))))
double code(double g, double h, double a) {
double tmp;
if (g <= -4.8e-5) {
tmp = cbrt((-g / a)) + cbrt(-2.0);
} else if (g <= 0.25) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + (-2.0 * cbrt(g));
} else {
tmp = cbrt(((-0.5 / a) * (g + g))) + cbrt(-2.0);
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= -4.8e-5) {
tmp = Math.cbrt((-g / a)) + Math.cbrt(-2.0);
} else if (g <= 0.25) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + (-2.0 * Math.cbrt(g));
} else {
tmp = Math.cbrt(((-0.5 / a) * (g + g))) + Math.cbrt(-2.0);
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= -4.8e-5) tmp = Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(-2.0)); elseif (g <= 0.25) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + Float64(-2.0 * cbrt(g))); else tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) + cbrt(-2.0)); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, -4.8e-5], N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 0.25], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-2.0 * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq -4.8 \cdot 10^{-5}:\\
\;\;\;\;\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-2}\\
\mathbf{elif}\;g \leq 0.25:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + -2 \cdot \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{-2}\\
\end{array}
\end{array}
if g < -4.8000000000000001e-5Initial program 31.4%
Simplified31.4%
Taylor expanded in g around -inf 31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in g around inf 16.0%
add-sqr-sqrt6.7%
sqrt-unprod10.3%
*-commutative10.3%
*-commutative10.3%
swap-sqr10.7%
*-commutative10.7%
*-commutative10.7%
swap-sqr10.7%
metadata-eval10.7%
metadata-eval10.7%
swap-sqr10.7%
count-210.7%
count-210.7%
frac-times10.7%
metadata-eval10.7%
metadata-eval10.7%
frac-times10.7%
swap-sqr10.3%
sqrt-unprod6.7%
add-sqr-sqrt16.0%
expm1-log1p-u8.9%
Applied egg-rr0.0%
Simplified56.4%
Taylor expanded in g around 0 56.4%
associate-*r/56.4%
mul-1-neg56.4%
Simplified56.4%
if -4.8000000000000001e-5 < g < 0.25Initial program 72.5%
Simplified72.5%
Taylor expanded in g around -inf 50.9%
*-commutative50.9%
Simplified50.9%
Taylor expanded in g around inf 17.6%
add-sqr-sqrt10.6%
sqrt-unprod34.4%
swap-sqr34.8%
count-234.8%
count-234.8%
swap-sqr34.8%
metadata-eval34.8%
metadata-eval34.8%
swap-sqr34.8%
*-commutative34.8%
*-commutative34.8%
frac-times34.9%
metadata-eval34.9%
metadata-eval34.9%
frac-times34.8%
swap-sqr34.4%
*-commutative34.4%
*-commutative34.4%
sqrt-unprod10.6%
Applied egg-rr17.6%
Simplified48.0%
if 0.25 < g Initial program 33.9%
Simplified33.9%
Taylor expanded in g around -inf 8.7%
*-commutative8.7%
Simplified8.7%
Taylor expanded in g around inf 14.9%
add-sqr-sqrt6.9%
sqrt-unprod11.3%
*-commutative11.3%
*-commutative11.3%
swap-sqr13.8%
*-commutative13.8%
*-commutative13.8%
swap-sqr13.8%
metadata-eval13.8%
metadata-eval13.8%
swap-sqr13.8%
count-213.8%
count-213.8%
frac-times13.7%
metadata-eval13.7%
metadata-eval13.7%
frac-times13.8%
swap-sqr11.3%
sqrt-unprod6.9%
add-sqr-sqrt14.9%
expm1-log1p-u9.7%
Applied egg-rr0.0%
Simplified46.4%
Final simplification50.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ -0.5 a) (+ g g)))))
(if (<= g -20000000000000.0)
(+ (cbrt (/ (- g) a)) (cbrt -2.0))
(if (<= g 1.5e-49) (+ (cbrt g) t_0) (+ t_0 (cbrt -2.0))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (g <= -20000000000000.0) {
tmp = cbrt((-g / a)) + cbrt(-2.0);
} else if (g <= 1.5e-49) {
tmp = cbrt(g) + t_0;
} else {
tmp = t_0 + cbrt(-2.0);
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((-0.5 / a) * (g + g)));
double tmp;
if (g <= -20000000000000.0) {
tmp = Math.cbrt((-g / a)) + Math.cbrt(-2.0);
} else if (g <= 1.5e-49) {
tmp = Math.cbrt(g) + t_0;
} else {
tmp = t_0 + Math.cbrt(-2.0);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) tmp = 0.0 if (g <= -20000000000000.0) tmp = Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(-2.0)); elseif (g <= 1.5e-49) tmp = Float64(cbrt(g) + t_0); else tmp = Float64(t_0 + cbrt(-2.0)); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -20000000000000.0], N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.5e-49], N[(N[Power[g, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision], N[(t$95$0 + N[Power[-2.0, 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 -20000000000000:\\
\;\;\;\;\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-2}\\
\mathbf{elif}\;g \leq 1.5 \cdot 10^{-49}:\\
\;\;\;\;\sqrt[3]{g} + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{-2}\\
\end{array}
\end{array}
if g < -2e13Initial program 29.1%
Simplified29.1%
Taylor expanded in g around -inf 29.3%
*-commutative29.3%
Simplified29.3%
Taylor expanded in g around inf 15.9%
add-sqr-sqrt6.9%
sqrt-unprod9.6%
*-commutative9.6%
*-commutative9.6%
swap-sqr10.0%
*-commutative10.0%
*-commutative10.0%
swap-sqr10.0%
metadata-eval10.0%
metadata-eval10.0%
swap-sqr10.0%
count-210.0%
count-210.0%
frac-times10.0%
metadata-eval10.0%
metadata-eval10.0%
frac-times10.0%
swap-sqr9.6%
sqrt-unprod6.9%
add-sqr-sqrt15.9%
expm1-log1p-u9.0%
Applied egg-rr0.0%
Simplified56.0%
Taylor expanded in g around 0 56.0%
associate-*r/56.0%
mul-1-neg56.0%
Simplified56.0%
if -2e13 < g < 1.5e-49Initial program 71.4%
Simplified71.4%
Taylor expanded in g around -inf 56.8%
*-commutative56.8%
Simplified56.8%
Taylor expanded in g around inf 17.6%
Taylor expanded in a around 0 17.6%
Simplified49.3%
if 1.5e-49 < g Initial program 37.3%
Simplified37.3%
Taylor expanded in g around -inf 9.3%
*-commutative9.3%
Simplified9.3%
Taylor expanded in g around inf 15.1%
add-sqr-sqrt7.0%
sqrt-unprod12.2%
*-commutative12.2%
*-commutative12.2%
swap-sqr14.4%
*-commutative14.4%
*-commutative14.4%
swap-sqr14.4%
metadata-eval14.4%
metadata-eval14.4%
swap-sqr14.4%
count-214.4%
count-214.4%
frac-times14.4%
metadata-eval14.4%
metadata-eval14.4%
frac-times14.4%
swap-sqr12.2%
sqrt-unprod7.0%
add-sqr-sqrt15.1%
expm1-log1p-u10.1%
Applied egg-rr0.0%
Simplified46.3%
Final simplification50.0%
(FPCore (g h a) :precision binary64 (+ (cbrt (/ (- g) a)) (cbrt (* (- g g) (/ -0.5 a)))))
double code(double g, double h, double a) {
return cbrt((-g / a)) + cbrt(((g - g) * (-0.5 / a)));
}
public static double code(double g, double h, double a) {
return Math.cbrt((-g / a)) + Math.cbrt(((g - g) * (-0.5 / a)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))) end
code[g_, h_, a_] := N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around -inf 77.5%
neg-mul-177.5%
Simplified77.5%
associate-*l/77.5%
*-commutative77.5%
associate-*r*77.5%
metadata-eval77.5%
neg-mul-177.5%
Applied egg-rr77.5%
Final simplification77.5%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ -0.5 a) (+ g g))) (cbrt -2.0)))
double code(double g, double h, double a) {
return cbrt(((-0.5 / a) * (g + g))) + cbrt(-2.0);
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-0.5 / a) * (g + g))) + Math.cbrt(-2.0);
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) + cbrt(-2.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[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{-2}
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around inf 15.9%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr18.1%
*-commutative18.1%
*-commutative18.1%
swap-sqr18.1%
metadata-eval18.1%
metadata-eval18.1%
swap-sqr18.1%
count-218.1%
count-218.1%
frac-times18.0%
metadata-eval18.0%
metadata-eval18.0%
frac-times18.1%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.9%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.3%
Final simplification46.3%
(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 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around inf 15.9%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr18.1%
*-commutative18.1%
*-commutative18.1%
swap-sqr18.1%
metadata-eval18.1%
metadata-eval18.1%
swap-sqr18.1%
count-218.1%
count-218.1%
frac-times18.0%
metadata-eval18.0%
metadata-eval18.0%
frac-times18.1%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.9%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.3%
Taylor expanded in g around 0 46.3%
associate-*r/46.3%
mul-1-neg46.3%
Simplified46.3%
Final simplification46.3%
(FPCore (g h a) :precision binary64 (+ (/ -2.0 (cbrt a)) (cbrt -2.0)))
double code(double g, double h, double a) {
return (-2.0 / cbrt(a)) + cbrt(-2.0);
}
public static double code(double g, double h, double a) {
return (-2.0 / Math.cbrt(a)) + Math.cbrt(-2.0);
}
function code(g, h, a) return Float64(Float64(-2.0 / cbrt(a)) + cbrt(-2.0)) end
code[g_, h_, a_] := N[(N[(-2.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{\sqrt[3]{a}} + \sqrt[3]{-2}
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around inf 15.9%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr18.1%
*-commutative18.1%
*-commutative18.1%
swap-sqr18.1%
metadata-eval18.1%
metadata-eval18.1%
swap-sqr18.1%
count-218.1%
count-218.1%
frac-times18.0%
metadata-eval18.0%
metadata-eval18.0%
frac-times18.1%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.9%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.3%
Applied egg-rr0.0%
Simplified5.1%
Final simplification5.1%
(FPCore (g h a) :precision binary64 (cbrt -2.0))
double code(double g, double h, double a) {
return cbrt(-2.0);
}
public static double code(double g, double h, double a) {
return Math.cbrt(-2.0);
}
function code(g, h, a) return cbrt(-2.0) end
code[g_, h_, a_] := N[Power[-2.0, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-2}
\end{array}
Initial program 42.7%
Simplified42.7%
Taylor expanded in g around -inf 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in g around inf 15.9%
add-sqr-sqrt7.8%
sqrt-unprod16.8%
*-commutative16.8%
*-commutative16.8%
swap-sqr18.1%
*-commutative18.1%
*-commutative18.1%
swap-sqr18.1%
metadata-eval18.1%
metadata-eval18.1%
swap-sqr18.1%
count-218.1%
count-218.1%
frac-times18.0%
metadata-eval18.0%
metadata-eval18.0%
frac-times18.1%
swap-sqr16.8%
sqrt-unprod7.8%
add-sqr-sqrt15.9%
expm1-log1p-u10.9%
Applied egg-rr0.0%
Simplified46.3%
Taylor expanded in g around 0 4.7%
Final simplification4.7%
herbie shell --seed 2024018
(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))))))))