
(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 8 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.3%
Simplified50.3%
Taylor expanded in g around -inf 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in g around -inf 74.2%
neg-mul-174.2%
Simplified74.2%
cbrt-prod96.5%
Applied egg-rr96.5%
Final simplification96.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (- g g) (/ -0.5 a)))))
(if (<= a -1.42e-83)
(+ t_0 (cbrt (/ 1.0 (/ a (- g)))))
(if (<= a 5e-89)
(+ (* (cbrt (/ 0.5 a)) (cbrt (* g -2.0))) (* -2.0 (cbrt (- g))))
(+ t_0 (cbrt (/ (- g) a)))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -1.42e-83) {
tmp = t_0 + cbrt((1.0 / (a / -g)));
} else if (a <= 5e-89) {
tmp = (cbrt((0.5 / a)) * cbrt((g * -2.0))) + (-2.0 * cbrt(-g));
} else {
tmp = t_0 + cbrt((-g / a));
}
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 <= -1.42e-83) {
tmp = t_0 + Math.cbrt((1.0 / (a / -g)));
} else if (a <= 5e-89) {
tmp = (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + (-2.0 * Math.cbrt(-g));
} else {
tmp = t_0 + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) tmp = 0.0 if (a <= -1.42e-83) tmp = Float64(t_0 + cbrt(Float64(1.0 / Float64(a / Float64(-g))))); elseif (a <= 5e-89) tmp = Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + Float64(-2.0 * cbrt(Float64(-g)))); else tmp = Float64(t_0 + cbrt(Float64(Float64(-g) / a))); 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, -1.42e-83], N[(t$95$0 + N[Power[N[(1.0 / N[(a / (-g)), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5e-89], N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[Power[(-g), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[((-g) / a), $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 -1.42 \cdot 10^{-83}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{1}{\frac{a}{-g}}}\\
\mathbf{elif}\;a \leq 5 \cdot 10^{-89}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + -2 \cdot \sqrt[3]{-g}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if a < -1.4199999999999999e-83Initial program 59.3%
Simplified59.3%
Taylor expanded in g around -inf 39.1%
*-commutative39.1%
Simplified39.1%
Taylor expanded in g around -inf 93.0%
neg-mul-193.0%
Simplified93.0%
associate-*l/93.0%
clear-num93.0%
*-commutative93.0%
associate-*r*93.0%
metadata-eval93.0%
Applied egg-rr93.0%
if -1.4199999999999999e-83 < a < 4.99999999999999967e-89Initial program 38.1%
Simplified38.1%
Taylor expanded in g around -inf 26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in g around inf 11.1%
cbrt-prod95.5%
Applied egg-rr11.1%
add-sqr-sqrt5.6%
sqrt-unprod4.9%
swap-sqr6.1%
count-26.1%
count-26.1%
swap-sqr6.1%
metadata-eval6.1%
metadata-eval6.1%
swap-sqr6.1%
*-commutative6.1%
*-commutative6.1%
frac-times6.1%
metadata-eval6.1%
metadata-eval6.1%
frac-times6.1%
swap-sqr4.9%
*-commutative4.9%
*-commutative4.9%
Applied egg-rr11.1%
Simplified95.5%
if 4.99999999999999967e-89 < a Initial program 58.1%
Simplified58.1%
Taylor expanded in g around -inf 24.5%
*-commutative24.5%
Simplified24.5%
Taylor expanded in g around -inf 93.5%
neg-mul-193.5%
Simplified93.5%
expm1-log1p-u68.1%
expm1-udef27.4%
associate-*l/27.4%
*-commutative27.4%
associate-*r*27.4%
metadata-eval27.4%
neg-mul-127.4%
Applied egg-rr27.4%
expm1-def68.1%
expm1-log1p93.6%
Simplified93.6%
Final simplification94.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 50.3%
Simplified50.3%
Taylor expanded in g around -inf 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in g around -inf 74.2%
neg-mul-174.2%
Simplified74.2%
associate-*l/74.2%
cbrt-div96.5%
*-commutative96.5%
associate-*r*96.5%
metadata-eval96.5%
neg-mul-196.5%
Applied egg-rr96.5%
Final simplification96.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (- g g) (/ -0.5 a)))))
(if (<= a -9.8e-99)
(+ t_0 (cbrt (/ 1.0 (/ a (- g)))))
(if (<= a 4.8e-89)
(+ (/ (cbrt (- g)) (cbrt a)) (cbrt -2.0))
(+ t_0 (cbrt (/ (- g) a)))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -9.8e-99) {
tmp = t_0 + cbrt((1.0 / (a / -g)));
} else if (a <= 4.8e-89) {
tmp = (cbrt(-g) / cbrt(a)) + cbrt(-2.0);
} else {
tmp = t_0 + cbrt((-g / a));
}
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 <= -9.8e-99) {
tmp = t_0 + Math.cbrt((1.0 / (a / -g)));
} else if (a <= 4.8e-89) {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-2.0);
} else {
tmp = t_0 + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) tmp = 0.0 if (a <= -9.8e-99) tmp = Float64(t_0 + cbrt(Float64(1.0 / Float64(a / Float64(-g))))); elseif (a <= 4.8e-89) tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-2.0)); else tmp = Float64(t_0 + cbrt(Float64(Float64(-g) / a))); 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, -9.8e-99], N[(t$95$0 + N[Power[N[(1.0 / N[(a / (-g)), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4.8e-89], 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[((-g) / a), $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 -9.8 \cdot 10^{-99}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{1}{\frac{a}{-g}}}\\
\mathbf{elif}\;a \leq 4.8 \cdot 10^{-89}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-2}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if a < -9.8000000000000006e-99Initial program 59.0%
Simplified59.0%
Taylor expanded in g around -inf 40.0%
*-commutative40.0%
Simplified40.0%
Taylor expanded in g around -inf 93.3%
neg-mul-193.3%
Simplified93.3%
associate-*l/93.3%
clear-num93.3%
*-commutative93.3%
associate-*r*93.3%
metadata-eval93.3%
Applied egg-rr93.3%
if -9.8000000000000006e-99 < a < 4.80000000000000032e-89Initial program 37.4%
Simplified37.4%
Taylor expanded in g around -inf 25.0%
*-commutative25.0%
Simplified25.0%
Taylor expanded in g around inf 10.8%
add-sqr-sqrt5.6%
sqrt-unprod4.8%
*-commutative4.8%
*-commutative4.8%
swap-sqr5.2%
*-commutative5.2%
*-commutative5.2%
swap-sqr5.2%
metadata-eval5.2%
metadata-eval5.2%
swap-sqr5.2%
count-25.2%
count-25.2%
frac-times5.2%
metadata-eval5.2%
metadata-eval5.2%
frac-times5.2%
swap-sqr4.8%
sqrt-unprod5.6%
add-sqr-sqrt10.8%
expm1-log1p-u6.2%
Applied egg-rr0.0%
Simplified41.3%
add-sqr-sqrt22.7%
sqrt-unprod12.0%
swap-sqr9.0%
count-29.0%
count-29.0%
swap-sqr9.0%
metadata-eval9.0%
metadata-eval9.0%
swap-sqr9.0%
*-commutative9.0%
*-commutative9.0%
frac-times9.0%
metadata-eval9.0%
metadata-eval9.0%
frac-times9.0%
swap-sqr12.0%
*-commutative12.0%
*-commutative12.0%
sqrt-unprod22.7%
add-sqr-sqrt41.3%
Applied egg-rr92.5%
Simplified92.5%
if 4.80000000000000032e-89 < a Initial program 58.1%
Simplified58.1%
Taylor expanded in g around -inf 24.5%
*-commutative24.5%
Simplified24.5%
Taylor expanded in g around -inf 93.5%
neg-mul-193.5%
Simplified93.5%
expm1-log1p-u68.1%
expm1-udef27.4%
associate-*l/27.4%
*-commutative27.4%
associate-*r*27.4%
metadata-eval27.4%
neg-mul-127.4%
Applied egg-rr27.4%
expm1-def68.1%
expm1-log1p93.6%
Simplified93.6%
Final simplification93.1%
(FPCore (g h a) :precision binary64 (if (or (<= g -8.5e-65) (not (<= g 2.6))) (+ (cbrt (/ (- g) a)) (cbrt -2.0)) (+ (cbrt (- g)) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
double tmp;
if ((g <= -8.5e-65) || !(g <= 2.6)) {
tmp = cbrt((-g / a)) + cbrt(-2.0);
} 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 <= -8.5e-65) || !(g <= 2.6)) {
tmp = Math.cbrt((-g / a)) + Math.cbrt(-2.0);
} else {
tmp = Math.cbrt(-g) + Math.cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if ((g <= -8.5e-65) || !(g <= 2.6)) tmp = Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(-2.0)); else tmp = Float64(cbrt(Float64(-g)) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); end return tmp end
code[g_, h_, a_] := If[Or[LessEqual[g, -8.5e-65], N[Not[LessEqual[g, 2.6]], $MachinePrecision]], N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[-2.0, 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 -8.5 \cdot 10^{-65} \lor \neg \left(g \leq 2.6\right):\\
\;\;\;\;\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\end{array}
\end{array}
if g < -8.5000000000000003e-65 or 2.60000000000000009 < g Initial program 45.9%
Simplified45.9%
Taylor expanded in g around -inf 28.6%
*-commutative28.6%
Simplified28.6%
Taylor expanded in g around inf 15.0%
add-sqr-sqrt6.9%
sqrt-unprod11.6%
*-commutative11.6%
*-commutative11.6%
swap-sqr17.3%
*-commutative17.3%
*-commutative17.3%
swap-sqr17.3%
metadata-eval17.3%
metadata-eval17.3%
swap-sqr17.3%
count-217.3%
count-217.3%
frac-times18.1%
metadata-eval18.1%
metadata-eval18.1%
frac-times17.3%
swap-sqr11.6%
sqrt-unprod6.9%
add-sqr-sqrt15.0%
expm1-log1p-u10.6%
Applied egg-rr0.0%
Simplified44.9%
Taylor expanded in g around 0 44.9%
neg-mul-144.9%
distribute-neg-frac44.9%
Simplified44.9%
if -8.5000000000000003e-65 < g < 2.60000000000000009Initial program 70.7%
Simplified70.7%
Taylor expanded in g around -inf 31.9%
*-commutative31.9%
Simplified31.9%
Taylor expanded in g around inf 16.5%
Taylor expanded in a around 0 16.5%
Simplified50.9%
Final simplification46.0%
(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 50.3%
Simplified50.3%
Taylor expanded in g around -inf 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in g around -inf 74.2%
neg-mul-174.2%
Simplified74.2%
expm1-log1p-u52.6%
expm1-udef26.4%
associate-*l/26.4%
*-commutative26.4%
associate-*r*26.4%
metadata-eval26.4%
neg-mul-126.4%
Applied egg-rr26.4%
expm1-def52.6%
expm1-log1p74.2%
Simplified74.2%
Final simplification74.2%
(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 50.3%
Simplified50.3%
Taylor expanded in g around -inf 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in g around inf 15.3%
add-sqr-sqrt6.9%
sqrt-unprod14.1%
*-commutative14.1%
*-commutative14.1%
swap-sqr19.4%
*-commutative19.4%
*-commutative19.4%
swap-sqr19.4%
metadata-eval19.4%
metadata-eval19.4%
swap-sqr19.4%
count-219.4%
count-219.4%
frac-times20.1%
metadata-eval20.1%
metadata-eval20.1%
frac-times19.4%
swap-sqr14.1%
sqrt-unprod6.9%
add-sqr-sqrt15.3%
expm1-log1p-u11.0%
Applied egg-rr0.0%
Simplified42.7%
Taylor expanded in g around 0 42.7%
neg-mul-142.7%
distribute-neg-frac42.7%
Simplified42.7%
Final simplification42.7%
(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 50.3%
Simplified50.3%
Taylor expanded in g around -inf 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in g around inf 15.3%
add-sqr-sqrt6.9%
sqrt-unprod14.1%
*-commutative14.1%
*-commutative14.1%
swap-sqr19.4%
*-commutative19.4%
*-commutative19.4%
swap-sqr19.4%
metadata-eval19.4%
metadata-eval19.4%
swap-sqr19.4%
count-219.4%
count-219.4%
frac-times20.1%
metadata-eval20.1%
metadata-eval20.1%
frac-times19.4%
swap-sqr14.1%
sqrt-unprod6.9%
add-sqr-sqrt15.3%
expm1-log1p-u11.0%
Applied egg-rr0.0%
Simplified42.7%
Taylor expanded in g around 0 4.6%
Final simplification4.6%
herbie shell --seed 2024010
(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))))))))