
(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 7 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
(let* ((t_0 (/ (pow h 2.0) g)) (t_1 (sqrt (- (* g g) (* h h)))))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_1 g)))
(cbrt (* (+ g t_1) (/ -1.0 (* 2.0 a)))))
5e+70)
(+
(cbrt (* (/ 0.5 a) (* -0.5 t_0)))
(/ (cbrt (* -0.5 (fma -0.5 t_0 (* 2.0 g)))) (cbrt a)))
(+ (cbrt (* (/ 0.5 a) (- g g))) (/ (cbrt g) (cbrt (- a)))))))
double code(double g, double h, double a) {
double t_0 = pow(h, 2.0) / g;
double t_1 = sqrt(((g * g) - (h * h)));
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 5e+70) {
tmp = cbrt(((0.5 / a) * (-0.5 * t_0))) + (cbrt((-0.5 * fma(-0.5, t_0, (2.0 * g)))) / cbrt(a));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) + (cbrt(g) / cbrt(-a));
}
return tmp;
}
function code(g, h, a) t_0 = Float64((h ^ 2.0) / g) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_1 - g))) + cbrt(Float64(Float64(g + t_1) * Float64(-1.0 / Float64(2.0 * a))))) <= 5e+70) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * t_0))) + Float64(cbrt(Float64(-0.5 * fma(-0.5, t_0, Float64(2.0 * g)))) / cbrt(a))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(cbrt(g) / cbrt(Float64(-a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$1), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 5e+70], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(-0.5 * N[(-0.5 * t$95$0 + N[(2.0 * g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[(-a), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{h}^{2}}{g}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_1 - g\right)} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-1}{2 \cdot a}} \leq 5 \cdot 10^{+70}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot t_0\right)} + \frac{\sqrt[3]{-0.5 \cdot \mathsf{fma}\left(-0.5, t_0, 2 \cdot g\right)}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{g}}{\sqrt[3]{-a}}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 5.0000000000000002e70Initial program 77.3%
Simplified77.3%
add-cube-cbrt77.2%
pow377.2%
pow277.2%
pow277.2%
Applied egg-rr77.2%
Taylor expanded in g around inf 35.7%
Taylor expanded in g around inf 81.2%
rem-cube-cbrt81.4%
associate-*r/81.4%
cbrt-div96.5%
*-commutative96.5%
+-commutative96.5%
fma-def96.5%
Applied egg-rr96.5%
+-commutative96.5%
fma-udef96.5%
associate-+l+96.5%
fma-def96.5%
*-lft-identity96.5%
*-lft-identity96.5%
distribute-rgt-out96.5%
metadata-eval96.5%
Simplified96.5%
if 5.0000000000000002e70 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 6.9%
Simplified6.9%
Taylor expanded in g around inf 6.2%
Taylor expanded in g around inf 66.7%
associate-*r/66.7%
neg-mul-166.7%
Simplified66.7%
frac-2neg66.7%
cbrt-div96.4%
remove-double-neg96.4%
Applied egg-rr96.4%
Final simplification96.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ (pow h 2.0) g)) (t_1 (sqrt (- (* g g) (* h h)))))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_1 g)))
(cbrt (* (+ g t_1) (/ -1.0 (* 2.0 a)))))
5e+81)
(+
(cbrt (* (/ 0.5 a) (* -0.5 t_0)))
(* (cbrt (fma -0.5 t_0 (* 2.0 g))) (cbrt (/ -0.5 a))))
(+ (cbrt (* (/ 0.5 a) (- g g))) (/ (cbrt g) (cbrt (- a)))))))
double code(double g, double h, double a) {
double t_0 = pow(h, 2.0) / g;
double t_1 = sqrt(((g * g) - (h * h)));
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 5e+81) {
tmp = cbrt(((0.5 / a) * (-0.5 * t_0))) + (cbrt(fma(-0.5, t_0, (2.0 * g))) * cbrt((-0.5 / a)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) + (cbrt(g) / cbrt(-a));
}
return tmp;
}
function code(g, h, a) t_0 = Float64((h ^ 2.0) / g) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_1 - g))) + cbrt(Float64(Float64(g + t_1) * Float64(-1.0 / Float64(2.0 * a))))) <= 5e+81) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * t_0))) + Float64(cbrt(fma(-0.5, t_0, Float64(2.0 * g))) * cbrt(Float64(-0.5 / a)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(cbrt(g) / cbrt(Float64(-a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$1), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 5e+81], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(-0.5 * t$95$0 + N[(2.0 * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[(-a), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{h}^{2}}{g}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_1 - g\right)} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-1}{2 \cdot a}} \leq 5 \cdot 10^{+81}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot t_0\right)} + \sqrt[3]{\mathsf{fma}\left(-0.5, t_0, 2 \cdot g\right)} \cdot \sqrt[3]{\frac{-0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{g}}{\sqrt[3]{-a}}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.9999999999999998e81Initial program 77.7%
Simplified77.7%
add-cube-cbrt77.6%
pow377.7%
pow277.7%
pow277.7%
Applied egg-rr77.7%
Taylor expanded in g around inf 36.4%
Taylor expanded in g around inf 81.6%
cbrt-prod96.2%
rem-cbrt-cube96.5%
*-un-lft-identity96.5%
*-un-lft-identity96.5%
+-commutative96.5%
fma-def96.5%
Applied egg-rr96.5%
+-commutative96.5%
fma-udef96.5%
associate-+l+96.5%
fma-def96.5%
*-lft-identity96.5%
*-lft-identity96.5%
distribute-rgt-out96.5%
metadata-eval96.5%
Simplified96.5%
if 4.9999999999999998e81 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 4.5%
Simplified4.5%
Taylor expanded in g around inf 4.7%
Taylor expanded in g around inf 65.9%
associate-*r/65.9%
neg-mul-165.9%
Simplified65.9%
frac-2neg65.9%
cbrt-div96.3%
remove-double-neg96.3%
Applied egg-rr96.3%
Final simplification96.4%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_0 g)))
(cbrt (* (+ g t_0) (/ -1.0 (* 2.0 a)))))
5e+70)
(+
(cbrt (* (/ 0.5 a) (* -0.5 (/ (pow h 2.0) g))))
(* (* (cbrt g) (cbrt (/ 1.0 a))) (* (cbrt -0.5) (cbrt 2.0))))
(+ (cbrt (* (/ 0.5 a) (- g g))) (/ (cbrt g) (cbrt (- a)))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + cbrt(((g + t_0) * (-1.0 / (2.0 * a))))) <= 5e+70) {
tmp = cbrt(((0.5 / a) * (-0.5 * (pow(h, 2.0) / g)))) + ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * cbrt(2.0)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) + (cbrt(g) / cbrt(-a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double tmp;
if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + Math.cbrt(((g + t_0) * (-1.0 / (2.0 * a))))) <= 5e+70) {
tmp = Math.cbrt(((0.5 / a) * (-0.5 * (Math.pow(h, 2.0) / g)))) + ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.cbrt(2.0)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) + (Math.cbrt(g) / Math.cbrt(-a));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_0 - g))) + cbrt(Float64(Float64(g + t_0) * Float64(-1.0 / Float64(2.0 * a))))) <= 5e+70) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * Float64((h ^ 2.0) / g)))) + Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * cbrt(2.0)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(cbrt(g) / cbrt(Float64(-a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$0), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 5e+70], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[(-a), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_0 - g\right)} + \sqrt[3]{\left(g + t_0\right) \cdot \frac{-1}{2 \cdot a}} \leq 5 \cdot 10^{+70}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \frac{{h}^{2}}{g}\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{g}}{\sqrt[3]{-a}}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 5.0000000000000002e70Initial program 77.3%
Simplified77.3%
Taylor expanded in h around 0 17.7%
Taylor expanded in g around inf 38.1%
*-commutative38.1%
associate-*r/38.1%
unpow-prod-down19.6%
pow1/342.3%
Applied egg-rr42.3%
unpow1/395.9%
Simplified95.9%
if 5.0000000000000002e70 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 6.9%
Simplified6.9%
Taylor expanded in g around inf 6.2%
Taylor expanded in g around inf 66.7%
associate-*r/66.7%
neg-mul-166.7%
Simplified66.7%
frac-2neg66.7%
cbrt-div96.4%
remove-double-neg96.4%
Applied egg-rr96.4%
Final simplification96.1%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (/ (cbrt g) (cbrt (- a)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + (cbrt(g) / cbrt(-a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + (Math.cbrt(g) / Math.cbrt(-a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(cbrt(g) / cbrt(Float64(-a)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $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]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{g}}{\sqrt[3]{-a}}
\end{array}
Initial program 44.3%
Simplified44.3%
Taylor expanded in g around inf 20.1%
Taylor expanded in g around inf 72.7%
associate-*r/72.7%
neg-mul-172.7%
Simplified72.7%
frac-2neg72.7%
cbrt-div94.5%
remove-double-neg94.5%
Applied egg-rr94.5%
Final simplification94.5%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (* (/ -0.5 a) (+ g g)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt(((-0.5 / a) * (g + g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt(((-0.5 / a) * (g + g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 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]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}
\end{array}
Initial program 44.3%
Simplified44.3%
Taylor expanded in g around inf 20.1%
Taylor expanded in g around inf 72.7%
Final simplification72.7%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 44.3%
Simplified44.3%
Taylor expanded in g around inf 20.1%
Taylor expanded in g around inf 72.7%
associate-*r/72.7%
neg-mul-172.7%
Simplified72.7%
Final simplification72.7%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ g a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt((g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(g / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 44.3%
Simplified44.3%
Taylor expanded in g around inf 20.1%
Taylor expanded in g around inf 72.7%
associate-*r/72.7%
neg-mul-172.7%
Simplified72.7%
expm1-log1p-u49.1%
expm1-udef28.2%
add-sqr-sqrt12.2%
sqrt-unprod7.9%
sqr-neg7.9%
sqrt-unprod0.6%
add-sqr-sqrt1.4%
Applied egg-rr1.4%
expm1-def1.1%
expm1-log1p1.4%
Simplified1.4%
Final simplification1.4%
herbie shell --seed 2023305
(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))))))))