
(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 (fma (/ (cbrt (* 2.0 g)) (cbrt a)) (cbrt -0.5) (* (/ (cbrt (* (/ h g) h)) (cbrt a)) (* (cbrt 0.5) (cbrt -0.5)))))
double code(double g, double h, double a) {
return fma((cbrt((2.0 * g)) / cbrt(a)), cbrt(-0.5), ((cbrt(((h / g) * h)) / cbrt(a)) * (cbrt(0.5) * cbrt(-0.5))));
}
function code(g, h, a) return fma(Float64(cbrt(Float64(2.0 * g)) / cbrt(a)), cbrt(-0.5), Float64(Float64(cbrt(Float64(Float64(h / g) * h)) / cbrt(a)) * Float64(cbrt(0.5) * cbrt(-0.5)))) end
code[g_, h_, a_] := N[(N[(N[Power[N[(2.0 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision] + N[(N[(N[Power[N[(N[(h / g), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[0.5, 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\sqrt[3]{2 \cdot g}}{\sqrt[3]{a}}, \sqrt[3]{-0.5}, \frac{\sqrt[3]{\frac{h}{g} \cdot h}}{\sqrt[3]{a}} \cdot \left(\sqrt[3]{0.5} \cdot \sqrt[3]{-0.5}\right)\right)
\end{array}
Initial program 45.6%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.2%
Applied rewrites92.8%
Applied rewrites97.6%
Applied rewrites98.3%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h))))
(t_1 (cbrt (/ (- g) a)))
(t_2 (pow (* 2.0 a) -1.0)))
(if (<=
(+
(cbrt (* t_2 (+ (- g) t_0)))
(cbrt (* (/ -1.0 (* 2.0 a)) (+ g t_0))))
5e+99)
(+ (cbrt (* (- (sqrt (* (+ h g) (- g h))) g) (/ 0.5 a))) t_1)
(+ (cbrt (* t_2 (* -2.0 g))) t_1))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = cbrt((-g / a));
double t_2 = pow((2.0 * a), -1.0);
double tmp;
if ((cbrt((t_2 * (-g + t_0))) + cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= 5e+99) {
tmp = cbrt(((sqrt(((h + g) * (g - h))) - g) * (0.5 / a))) + t_1;
} else {
tmp = cbrt((t_2 * (-2.0 * g))) + t_1;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = Math.cbrt((-g / a));
double t_2 = Math.pow((2.0 * a), -1.0);
double tmp;
if ((Math.cbrt((t_2 * (-g + t_0))) + Math.cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= 5e+99) {
tmp = Math.cbrt(((Math.sqrt(((h + g) * (g - h))) - g) * (0.5 / a))) + t_1;
} else {
tmp = Math.cbrt((t_2 * (-2.0 * g))) + t_1;
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = cbrt(Float64(Float64(-g) / a)) t_2 = Float64(2.0 * a) ^ -1.0 tmp = 0.0 if (Float64(cbrt(Float64(t_2 * Float64(Float64(-g) + t_0))) + cbrt(Float64(Float64(-1.0 / Float64(2.0 * a)) * Float64(g + t_0)))) <= 5e+99) tmp = Float64(cbrt(Float64(Float64(sqrt(Float64(Float64(h + g) * Float64(g - h))) - g) * Float64(0.5 / a))) + t_1); else tmp = Float64(cbrt(Float64(t_2 * Float64(-2.0 * g))) + t_1); 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]}, Block[{t$95$1 = N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(t$95$2 * N[((-g) + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(g + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 5e+99], N[(N[Power[N[(N[(N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[Power[N[(t$95$2 * N[(-2.0 * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := \sqrt[3]{\frac{-g}{a}}\\
t_2 := {\left(2 \cdot a\right)}^{-1}\\
\mathbf{if}\;\sqrt[3]{t\_2 \cdot \left(\left(-g\right) + t\_0\right)} + \sqrt[3]{\frac{-1}{2 \cdot a} \cdot \left(g + t\_0\right)} \leq 5 \cdot 10^{+99}:\\
\;\;\;\;\sqrt[3]{\left(\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g\right) \cdot \frac{0.5}{a}} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t\_2 \cdot \left(-2 \cdot g\right)} + t\_1\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 5.00000000000000008e99Initial program 82.7%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6449.3
Applied rewrites49.3%
Applied rewrites49.3%
if 5.00000000000000008e99 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 0.2%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f641.7
Applied rewrites1.7%
Taylor expanded in g around -inf
lower-*.f6413.0
Applied rewrites13.0%
Final simplification33.0%
(FPCore (g h a) :precision binary64 (fma (pow (cbrt a) -1.0) (* (cbrt g) (cbrt -1.0)) (cbrt (* -0.25 (/ (* (/ h g) h) a)))))
double code(double g, double h, double a) {
return fma(pow(cbrt(a), -1.0), (cbrt(g) * cbrt(-1.0)), cbrt((-0.25 * (((h / g) * h) / a))));
}
function code(g, h, a) return fma((cbrt(a) ^ -1.0), Float64(cbrt(g) * cbrt(-1.0)), cbrt(Float64(-0.25 * Float64(Float64(Float64(h / g) * h) / a)))) end
code[g_, h_, a_] := N[(N[Power[N[Power[a, 1/3], $MachinePrecision], -1.0], $MachinePrecision] * N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(-0.25 * N[(N[(N[(h / g), $MachinePrecision] * h), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left({\left(\sqrt[3]{a}\right)}^{-1}, \sqrt[3]{g} \cdot \sqrt[3]{-1}, \sqrt[3]{-0.25 \cdot \frac{\frac{h}{g} \cdot h}{a}}\right)
\end{array}
Initial program 45.6%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.2%
Applied rewrites92.8%
Applied rewrites97.6%
Applied rewrites96.9%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ (* h h) g)))
(if (<= (* h h) 2e+288)
(+
(cbrt (* (pow (* 2.0 a) -1.0) (* t_0 -0.5)))
(cbrt (* (/ -1.0 (* 2.0 a)) (+ g (fma -0.5 t_0 g)))))
(* (* (cbrt (/ g a)) (cbrt -0.5)) (cbrt 2.0)))))
double code(double g, double h, double a) {
double t_0 = (h * h) / g;
double tmp;
if ((h * h) <= 2e+288) {
tmp = cbrt((pow((2.0 * a), -1.0) * (t_0 * -0.5))) + cbrt(((-1.0 / (2.0 * a)) * (g + fma(-0.5, t_0, g))));
} else {
tmp = (cbrt((g / a)) * cbrt(-0.5)) * cbrt(2.0);
}
return tmp;
}
function code(g, h, a) t_0 = Float64(Float64(h * h) / g) tmp = 0.0 if (Float64(h * h) <= 2e+288) tmp = Float64(cbrt(Float64((Float64(2.0 * a) ^ -1.0) * Float64(t_0 * -0.5))) + cbrt(Float64(Float64(-1.0 / Float64(2.0 * a)) * Float64(g + fma(-0.5, t_0, g))))); else tmp = Float64(Float64(cbrt(Float64(g / a)) * cbrt(-0.5)) * cbrt(2.0)); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision]}, If[LessEqual[N[(h * h), $MachinePrecision], 2e+288], N[(N[Power[N[(N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision] * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(g + N[(-0.5 * t$95$0 + g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{h \cdot h}{g}\\
\mathbf{if}\;h \cdot h \leq 2 \cdot 10^{+288}:\\
\;\;\;\;\sqrt[3]{{\left(2 \cdot a\right)}^{-1} \cdot \left(t\_0 \cdot -0.5\right)} + \sqrt[3]{\frac{-1}{2 \cdot a} \cdot \left(g + \mathsf{fma}\left(-0.5, t\_0, g\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-0.5}\right) \cdot \sqrt[3]{2}\\
\end{array}
\end{array}
if (*.f64 h h) < 2e288Initial program 48.9%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in h around 0
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6477.0
Applied rewrites77.0%
if 2e288 < (*.f64 h h) Initial program 0.0%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites48.7%
Taylor expanded in g around inf
Applied rewrites47.6%
Final simplification75.0%
(FPCore (g h a) :precision binary64 (fma (cbrt (/ g a)) (cbrt -1.0) (cbrt (* -0.25 (* (/ h a) (/ h g))))))
double code(double g, double h, double a) {
return fma(cbrt((g / a)), cbrt(-1.0), cbrt((-0.25 * ((h / a) * (h / g)))));
}
function code(g, h, a) return fma(cbrt(Float64(g / a)), cbrt(-1.0), cbrt(Float64(-0.25 * Float64(Float64(h / a) * Float64(h / g))))) end
code[g_, h_, a_] := N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(-0.25 * N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sqrt[3]{\frac{g}{a}}, \sqrt[3]{-1}, \sqrt[3]{-0.25 \cdot \left(\frac{h}{a} \cdot \frac{h}{g}\right)}\right)
\end{array}
Initial program 45.6%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.2%
Applied rewrites75.0%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (pow (* 2.0 a) -1.0) (* -0.5 (/ (* h h) g)))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt((pow((2.0 * a), -1.0) * (-0.5 * ((h * h) / g)))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt((Math.pow((2.0 * a), -1.0) * (-0.5 * ((h * h) / g)))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64((Float64(2.0 * a) ^ -1.0) * Float64(-0.5 * Float64(Float64(h * h) / g)))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision] * N[(-0.5 * N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{{\left(2 \cdot a\right)}^{-1} \cdot \left(-0.5 \cdot \frac{h \cdot h}{g}\right)} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 45.6%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6427.9
Applied rewrites27.9%
Taylor expanded in g around inf
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6472.0
Applied rewrites72.0%
Final simplification72.0%
(FPCore (g h a) :precision binary64 (fma (cbrt (/ 0.5 a)) (- (cbrt (* g 2.0))) (cbrt (* 0.0 (/ 0.5 a)))))
double code(double g, double h, double a) {
return fma(cbrt((0.5 / a)), -cbrt((g * 2.0)), cbrt((0.0 * (0.5 / a))));
}
function code(g, h, a) return fma(cbrt(Float64(0.5 / a)), Float64(-cbrt(Float64(g * 2.0))), cbrt(Float64(0.0 * Float64(0.5 / a)))) end
code[g_, h_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * (-N[Power[N[(g * 2.0), $MachinePrecision], 1/3], $MachinePrecision]) + N[Power[N[(0.0 * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sqrt[3]{\frac{0.5}{a}}, -\sqrt[3]{g \cdot 2}, \sqrt[3]{0 \cdot \frac{0.5}{a}}\right)
\end{array}
Initial program 45.6%
lift-+.f64N/A
+-commutativeN/A
lift-cbrt.f64N/A
lift-*.f64N/A
cbrt-prodN/A
pow1/3N/A
lower-fma.f64N/A
Applied rewrites49.1%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
lower-cbrt.f64N/A
lower-*.f6432.9
Applied rewrites32.9%
Taylor expanded in g around inf
lower-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6496.8
Applied rewrites96.8%
Final simplification96.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (pow (* 2.0 a) -1.0) (* -2.0 g))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt((pow((2.0 * a), -1.0) * (-2.0 * g))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt((Math.pow((2.0 * a), -1.0) * (-2.0 * g))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64((Float64(2.0 * a) ^ -1.0) * Float64(-2.0 * g))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision] * N[(-2.0 * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{{\left(2 \cdot a\right)}^{-1} \cdot \left(-2 \cdot g\right)} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 45.6%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6427.9
Applied rewrites27.9%
Taylor expanded in g around -inf
lower-*.f6415.2
Applied rewrites15.2%
Final simplification15.2%
(FPCore (g h a) :precision binary64 0.0)
double code(double g, double h, double a) {
return 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 = 0.0d0
end function
public static double code(double g, double h, double a) {
return 0.0;
}
def code(g, h, a): return 0.0
function code(g, h, a) return 0.0 end
function tmp = code(g, h, a) tmp = 0.0; end
code[g_, h_, a_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 45.6%
lift-+.f64N/A
+-commutativeN/A
lift-sqrt.f64N/A
pow1/2N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
*-commutativeN/A
unpow-prod-downN/A
lower-fma.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower--.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
+-commutativeN/A
lower-+.f6412.2
Applied rewrites12.2%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites2.9%
Applied rewrites2.9%
herbie shell --seed 2024326
(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))))))))