
(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 10 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 (/ 1.0 a)) (cbrt 0.5)) (fma (cbrt g) (* (cbrt -1.0) (cbrt 2.0)) (cbrt (fma -0.5 (* h (/ h g)) (/ (* 0.5 (* h (- g g))) g))))))
double code(double g, double h, double a) {
return (cbrt((1.0 / a)) * cbrt(0.5)) * fma(cbrt(g), (cbrt(-1.0) * cbrt(2.0)), cbrt(fma(-0.5, (h * (h / g)), ((0.5 * (h * (g - g))) / g))));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(1.0 / a)) * cbrt(0.5)) * fma(cbrt(g), Float64(cbrt(-1.0) * cbrt(2.0)), cbrt(fma(-0.5, Float64(h * Float64(h / g)), Float64(Float64(0.5 * Float64(h * Float64(g - g))) / g))))) end
code[g_, h_, a_] := N[(N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(-0.5 * N[(h * N[(h / g), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(h * N[(g - g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{0.5}\right) \cdot \mathsf{fma}\left(\sqrt[3]{g}, \sqrt[3]{-1} \cdot \sqrt[3]{2}, \sqrt[3]{\mathsf{fma}\left(-0.5, h \cdot \frac{h}{g}, \frac{0.5 \cdot \left(h \cdot \left(g - g\right)\right)}{g}\right)}\right)
\end{array}
Initial program 48.3%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.9
Applied rewrites31.9%
lift-+.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
cbrt-prodN/A
pow1/3N/A
lift-cbrt.f64N/A
lift-*.f64N/A
Applied rewrites17.0%
Taylor expanded in h around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites89.0%
Applied rewrites97.3%
Final simplification97.3%
(FPCore (g h a)
:precision binary64
(if (<= (* h h) 2e+300)
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (/ (* -0.5 (* h h)) g)))
(/ (cbrt (+ g g)) (cbrt (* a -2.0))))
(*
(pow (* 2.0 a) -0.3333333333333333)
(* (cbrt g) (* (cbrt -1.0) (cbrt 2.0))))))
double code(double g, double h, double a) {
double tmp;
if ((h * h) <= 2e+300) {
tmp = cbrt(((1.0 / (2.0 * a)) * ((-0.5 * (h * h)) / g))) + (cbrt((g + g)) / cbrt((a * -2.0)));
} else {
tmp = pow((2.0 * a), -0.3333333333333333) * (cbrt(g) * (cbrt(-1.0) * cbrt(2.0)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((h * h) <= 2e+300) {
tmp = Math.cbrt(((1.0 / (2.0 * a)) * ((-0.5 * (h * h)) / g))) + (Math.cbrt((g + g)) / Math.cbrt((a * -2.0)));
} else {
tmp = Math.pow((2.0 * a), -0.3333333333333333) * (Math.cbrt(g) * (Math.cbrt(-1.0) * Math.cbrt(2.0)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (Float64(h * h) <= 2e+300) tmp = Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-0.5 * Float64(h * h)) / g))) + Float64(cbrt(Float64(g + g)) / cbrt(Float64(a * -2.0)))); else tmp = Float64((Float64(2.0 * a) ^ -0.3333333333333333) * Float64(cbrt(g) * Float64(cbrt(-1.0) * cbrt(2.0)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[N[(h * h), $MachinePrecision], 2e+300], N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(h * h), $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(g + g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(2.0 * a), $MachinePrecision], -0.3333333333333333], $MachinePrecision] * N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \cdot h \leq 2 \cdot 10^{+300}:\\
\;\;\;\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \frac{-0.5 \cdot \left(h \cdot h\right)}{g}} + \frac{\sqrt[3]{g + g}}{\sqrt[3]{a \cdot -2}}\\
\mathbf{else}:\\
\;\;\;\;{\left(2 \cdot a\right)}^{-0.3333333333333333} \cdot \left(\sqrt[3]{g} \cdot \left(\sqrt[3]{-1} \cdot \sqrt[3]{2}\right)\right)\\
\end{array}
\end{array}
if (*.f64 h h) < 2.0000000000000001e300Initial program 50.5%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
*-lft-identityN/A
cbrt-divN/A
Applied rewrites53.0%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
Taylor expanded in g around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-neg.f6496.1
Applied rewrites96.1%
if 2.0000000000000001e300 < (*.f64 h h) Initial program 0.0%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
lift-+.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
cbrt-prodN/A
pow1/3N/A
lift-cbrt.f64N/A
lift-*.f64N/A
Applied rewrites1.1%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6465.7
Applied rewrites65.7%
Final simplification94.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ 1.0 (* 2.0 a))))
(if (<= (* h h) 2e+293)
(+
(cbrt (* t_0 (/ (* -0.5 (* h h)) g)))
(/ (cbrt (+ g g)) (cbrt (* a -2.0))))
(+ (cbrt (* t_0 (* (/ h g) (* h -0.5)))) (cbrt (/ g (- a)))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double tmp;
if ((h * h) <= 2e+293) {
tmp = cbrt((t_0 * ((-0.5 * (h * h)) / g))) + (cbrt((g + g)) / cbrt((a * -2.0)));
} else {
tmp = cbrt((t_0 * ((h / g) * (h * -0.5)))) + cbrt((g / -a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double tmp;
if ((h * h) <= 2e+293) {
tmp = Math.cbrt((t_0 * ((-0.5 * (h * h)) / g))) + (Math.cbrt((g + g)) / Math.cbrt((a * -2.0)));
} else {
tmp = Math.cbrt((t_0 * ((h / g) * (h * -0.5)))) + Math.cbrt((g / -a));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) tmp = 0.0 if (Float64(h * h) <= 2e+293) tmp = Float64(cbrt(Float64(t_0 * Float64(Float64(-0.5 * Float64(h * h)) / g))) + Float64(cbrt(Float64(g + g)) / cbrt(Float64(a * -2.0)))); else tmp = Float64(cbrt(Float64(t_0 * Float64(Float64(h / g) * Float64(h * -0.5)))) + cbrt(Float64(g / Float64(-a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h * h), $MachinePrecision], 2e+293], N[(N[Power[N[(t$95$0 * N[(N[(-0.5 * N[(h * h), $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(g + g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(t$95$0 * N[(N[(h / g), $MachinePrecision] * N[(h * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
\mathbf{if}\;h \cdot h \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\sqrt[3]{t\_0 \cdot \frac{-0.5 \cdot \left(h \cdot h\right)}{g}} + \frac{\sqrt[3]{g + g}}{\sqrt[3]{a \cdot -2}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t\_0 \cdot \left(\frac{h}{g} \cdot \left(h \cdot -0.5\right)\right)} + \sqrt[3]{\frac{g}{-a}}\\
\end{array}
\end{array}
if (*.f64 h h) < 1.9999999999999998e293Initial program 50.9%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-2negN/A
*-lft-identityN/A
cbrt-divN/A
Applied rewrites53.4%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6426.3
Applied rewrites26.3%
Taylor expanded in g around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-neg.f6496.1
Applied rewrites96.1%
if 1.9999999999999998e293 < (*.f64 h h) Initial program 0.0%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f640.1
Applied rewrites0.1%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6418.8
Applied rewrites18.8%
Applied rewrites55.4%
Final simplification94.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ 1.0 (* 2.0 a))))
(if (<= t_0 5e+61)
(+ (cbrt (* t_0 (* (/ h g) (* h -0.5)))) (cbrt (/ g (- a))))
(*
(pow (* 2.0 a) -0.3333333333333333)
(+ (cbrt (fma (* h h) (/ -0.5 g) (* h 0.0))) (cbrt (* g -2.0)))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double tmp;
if (t_0 <= 5e+61) {
tmp = cbrt((t_0 * ((h / g) * (h * -0.5)))) + cbrt((g / -a));
} else {
tmp = pow((2.0 * a), -0.3333333333333333) * (cbrt(fma((h * h), (-0.5 / g), (h * 0.0))) + cbrt((g * -2.0)));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) tmp = 0.0 if (t_0 <= 5e+61) tmp = Float64(cbrt(Float64(t_0 * Float64(Float64(h / g) * Float64(h * -0.5)))) + cbrt(Float64(g / Float64(-a)))); else tmp = Float64((Float64(2.0 * a) ^ -0.3333333333333333) * Float64(cbrt(fma(Float64(h * h), Float64(-0.5 / g), Float64(h * 0.0))) + cbrt(Float64(g * -2.0)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+61], N[(N[Power[N[(t$95$0 * N[(N[(h / g), $MachinePrecision] * N[(h * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(2.0 * a), $MachinePrecision], -0.3333333333333333], $MachinePrecision] * N[(N[Power[N[(N[(h * h), $MachinePrecision] * N[(-0.5 / g), $MachinePrecision] + N[(h * 0.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+61}:\\
\;\;\;\;\sqrt[3]{t\_0 \cdot \left(\frac{h}{g} \cdot \left(h \cdot -0.5\right)\right)} + \sqrt[3]{\frac{g}{-a}}\\
\mathbf{else}:\\
\;\;\;\;{\left(2 \cdot a\right)}^{-0.3333333333333333} \cdot \left(\sqrt[3]{\mathsf{fma}\left(h \cdot h, \frac{-0.5}{g}, h \cdot 0\right)} + \sqrt[3]{g \cdot -2}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 5.00000000000000018e61Initial program 50.9%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6427.3
Applied rewrites27.3%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.9
Applied rewrites81.9%
Applied rewrites84.6%
if 5.00000000000000018e61 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 39.4%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-+.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
cbrt-prodN/A
pow1/3N/A
lift-cbrt.f64N/A
lift-*.f64N/A
Applied rewrites30.2%
Taylor expanded in h around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites89.6%
Applied rewrites85.1%
Final simplification84.7%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 1.0 (* 2.0 a)) (* (/ h g) (* h -0.5)))) (cbrt (/ g (- a)))))
double code(double g, double h, double a) {
return cbrt(((1.0 / (2.0 * a)) * ((h / g) * (h * -0.5)))) + cbrt((g / -a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((1.0 / (2.0 * a)) * ((h / g) * (h * -0.5)))) + Math.cbrt((g / -a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(h / g) * Float64(h * -0.5)))) + cbrt(Float64(g / Float64(-a)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(N[(h / g), $MachinePrecision] * N[(h * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\frac{h}{g} \cdot \left(h \cdot -0.5\right)\right)} + \sqrt[3]{\frac{g}{-a}}
\end{array}
Initial program 48.3%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6425.6
Applied rewrites25.6%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
Applied rewrites75.7%
Final simplification75.7%
(FPCore (g h a) :precision binary64 (+ (cbrt (/ g (- a))) (cbrt (/ (* 0.5 (/ (* -0.5 (* h h)) g)) a))))
double code(double g, double h, double a) {
return cbrt((g / -a)) + cbrt(((0.5 * ((-0.5 * (h * h)) / g)) / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt((g / -a)) + Math.cbrt(((0.5 * ((-0.5 * (h * h)) / g)) / a));
}
function code(g, h, a) return Float64(cbrt(Float64(g / Float64(-a))) + cbrt(Float64(Float64(0.5 * Float64(Float64(-0.5 * Float64(h * h)) / g)) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 * N[(N[(-0.5 * N[(h * h), $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{-a}} + \sqrt[3]{\frac{0.5 \cdot \frac{-0.5 \cdot \left(h \cdot h\right)}{g}}{a}}
\end{array}
Initial program 48.3%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6425.6
Applied rewrites25.6%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6473.5
Applied rewrites73.5%
Final simplification73.5%
(FPCore (g h a) :precision binary64 (+ (cbrt (/ g (- a))) (cbrt (/ (* (* h h) -0.25) (* a g)))))
double code(double g, double h, double a) {
return cbrt((g / -a)) + cbrt((((h * h) * -0.25) / (a * g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt((g / -a)) + Math.cbrt((((h * h) * -0.25) / (a * g)));
}
function code(g, h, a) return Float64(cbrt(Float64(g / Float64(-a))) + cbrt(Float64(Float64(Float64(h * h) * -0.25) / Float64(a * g)))) end
code[g_, h_, a_] := N[(N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(N[(h * h), $MachinePrecision] * -0.25), $MachinePrecision] / N[(a * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{-a}} + \sqrt[3]{\frac{\left(h \cdot h\right) \cdot -0.25}{a \cdot g}}
\end{array}
Initial program 48.3%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6425.6
Applied rewrites25.6%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6470.2
Applied rewrites70.2%
Final simplification70.2%
(FPCore (g h a) :precision binary64 (let* ((t_0 (cbrt (/ g (- a))))) (+ t_0 t_0)))
double code(double g, double h, double a) {
double t_0 = cbrt((g / -a));
return t_0 + t_0;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt((g / -a));
return t_0 + t_0;
}
function code(g, h, a) t_0 = cbrt(Float64(g / Float64(-a))) return Float64(t_0 + t_0) end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]}, N[(t$95$0 + t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{-a}}\\
t\_0 + t\_0
\end{array}
\end{array}
Initial program 48.3%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6425.6
Applied rewrites25.6%
Taylor expanded in g around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
Taylor expanded in g around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6415.4
Applied rewrites15.4%
Final simplification15.4%
(FPCore (g h a) :precision binary64 (* (cbrt (/ (* g 0.0) a)) (- (cbrt 0.5))))
double code(double g, double h, double a) {
return cbrt(((g * 0.0) / a)) * -cbrt(0.5);
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g * 0.0) / a)) * -Math.cbrt(0.5);
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g * 0.0) / a)) * Float64(-cbrt(0.5))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g * 0.0), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision] * (-N[Power[0.5, 1/3], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g \cdot 0}{a}} \cdot \left(-\sqrt[3]{0.5}\right)
\end{array}
Initial program 48.3%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.9
Applied rewrites31.9%
lift-+.f64N/A
+-commutativeN/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
sqrt-prodN/A
pow1/2N/A
lower-fma.f64N/A
lower-sqrt.f64N/A
pow1/2N/A
lower-sqrt.f642.9
Applied rewrites2.9%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites3.0%
Final simplification3.0%
(FPCore (g h a) :precision binary64 (* (pow (* 2.0 a) -0.3333333333333333) 0.0))
double code(double g, double h, double a) {
return pow((2.0 * a), -0.3333333333333333) * 0.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 * a) ** (-0.3333333333333333d0)) * 0.0d0
end function
public static double code(double g, double h, double a) {
return Math.pow((2.0 * a), -0.3333333333333333) * 0.0;
}
def code(g, h, a): return math.pow((2.0 * a), -0.3333333333333333) * 0.0
function code(g, h, a) return Float64((Float64(2.0 * a) ^ -0.3333333333333333) * 0.0) end
function tmp = code(g, h, a) tmp = ((2.0 * a) ^ -0.3333333333333333) * 0.0; end
code[g_, h_, a_] := N[(N[Power[N[(2.0 * a), $MachinePrecision], -0.3333333333333333], $MachinePrecision] * 0.0), $MachinePrecision]
\begin{array}{l}
\\
{\left(2 \cdot a\right)}^{-0.3333333333333333} \cdot 0
\end{array}
Initial program 48.3%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.9
Applied rewrites31.9%
lift-+.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
cbrt-prodN/A
pow1/3N/A
lift-cbrt.f64N/A
lift-*.f64N/A
Applied rewrites17.0%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-cbrt.f64N/A
+-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
lower-*.f641.6
Applied rewrites1.6%
Applied rewrites1.6%
herbie shell --seed 2024231
(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))))))))