
(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 (+ (pow (cbrt (/ (* -2.0 a) (- g (* (- g) -1.0)))) -1.0) (* (cbrt (- g)) (pow (cbrt a) -1.0))))
double code(double g, double h, double a) {
return pow(cbrt(((-2.0 * a) / (g - (-g * -1.0)))), -1.0) + (cbrt(-g) * pow(cbrt(a), -1.0));
}
public static double code(double g, double h, double a) {
return Math.pow(Math.cbrt(((-2.0 * a) / (g - (-g * -1.0)))), -1.0) + (Math.cbrt(-g) * Math.pow(Math.cbrt(a), -1.0));
}
function code(g, h, a) return Float64((cbrt(Float64(Float64(-2.0 * a) / Float64(g - Float64(Float64(-g) * -1.0)))) ^ -1.0) + Float64(cbrt(Float64(-g)) * (cbrt(a) ^ -1.0))) end
code[g_, h_, a_] := N[(N[Power[N[Power[N[(N[(-2.0 * a), $MachinePrecision] / N[(g - N[((-g) * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], -1.0], $MachinePrecision] + N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[N[Power[a, 1/3], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\sqrt[3]{\frac{-2 \cdot a}{g - \left(-g\right) \cdot -1}}\right)}^{-1} + \sqrt[3]{-g} \cdot {\left(\sqrt[3]{a}\right)}^{-1}
\end{array}
Initial program 40.4%
Applied rewrites40.5%
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.f6423.1
Applied rewrites23.1%
Applied rewrites45.2%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f6495.9
Applied rewrites95.9%
Final simplification95.9%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (/ (- g) a))))
(if (<= g -3.65e+152)
(+ t_0 (cbrt (* -0.25 (* (/ h g) (/ h a)))))
(if (<= g -4.8e-138)
(+
(pow
(* (cbrt (/ -1.0 (- (sqrt (* (+ h g) (- g h))) g))) (cbrt (* -2.0 a)))
-1.0)
(cbrt (/ (- (- g) (- g)) (* a 2.0))))
(if (<= g 1.2e-264)
(+ (/ (cbrt (* (* -0.25 (/ h g)) h)) (cbrt a)) t_0)
(+
(pow (cbrt (/ (* -2.0 a) (- g (* (- g) -1.0)))) -1.0)
(/
(cbrt (* -0.5 (fma (sqrt (+ h g)) (sqrt (- g h)) g)))
(cbrt a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt((-g / a));
double tmp;
if (g <= -3.65e+152) {
tmp = t_0 + cbrt((-0.25 * ((h / g) * (h / a))));
} else if (g <= -4.8e-138) {
tmp = pow((cbrt((-1.0 / (sqrt(((h + g) * (g - h))) - g))) * cbrt((-2.0 * a))), -1.0) + cbrt(((-g - -g) / (a * 2.0)));
} else if (g <= 1.2e-264) {
tmp = (cbrt(((-0.25 * (h / g)) * h)) / cbrt(a)) + t_0;
} else {
tmp = pow(cbrt(((-2.0 * a) / (g - (-g * -1.0)))), -1.0) + (cbrt((-0.5 * fma(sqrt((h + g)), sqrt((g - h)), g))) / cbrt(a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (g <= -3.65e+152) tmp = Float64(t_0 + cbrt(Float64(-0.25 * Float64(Float64(h / g) * Float64(h / a))))); elseif (g <= -4.8e-138) tmp = Float64((Float64(cbrt(Float64(-1.0 / Float64(sqrt(Float64(Float64(h + g) * Float64(g - h))) - g))) * cbrt(Float64(-2.0 * a))) ^ -1.0) + cbrt(Float64(Float64(Float64(-g) - Float64(-g)) / Float64(a * 2.0)))); elseif (g <= 1.2e-264) tmp = Float64(Float64(cbrt(Float64(Float64(-0.25 * Float64(h / g)) * h)) / cbrt(a)) + t_0); else tmp = Float64((cbrt(Float64(Float64(-2.0 * a) / Float64(g - Float64(Float64(-g) * -1.0)))) ^ -1.0) + Float64(cbrt(Float64(-0.5 * fma(sqrt(Float64(h + g)), sqrt(Float64(g - h)), g))) / cbrt(a))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -3.65e+152], N[(t$95$0 + N[Power[N[(-0.25 * N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, -4.8e-138], N[(N[Power[N[(N[Power[N[(-1.0 / N[(N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] + N[Power[N[(N[((-g) - (-g)), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.2e-264], N[(N[(N[Power[N[(N[(-0.25 * N[(h / g), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[Power[N[Power[N[(N[(-2.0 * a), $MachinePrecision] / N[(g - N[((-g) * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], -1.0], $MachinePrecision] + N[(N[Power[N[(-0.5 * N[(N[Sqrt[N[(h + g), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(g - h), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;g \leq -3.65 \cdot 10^{+152}:\\
\;\;\;\;t\_0 + \sqrt[3]{-0.25 \cdot \left(\frac{h}{g} \cdot \frac{h}{a}\right)}\\
\mathbf{elif}\;g \leq -4.8 \cdot 10^{-138}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{-1}{\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g}} \cdot \sqrt[3]{-2 \cdot a}\right)}^{-1} + \sqrt[3]{\frac{\left(-g\right) - \left(-g\right)}{a \cdot 2}}\\
\mathbf{elif}\;g \leq 1.2 \cdot 10^{-264}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-0.25 \cdot \frac{h}{g}\right) \cdot h}}{\sqrt[3]{a}} + t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{-2 \cdot a}{g - \left(-g\right) \cdot -1}}\right)}^{-1} + \frac{\sqrt[3]{-0.5 \cdot \mathsf{fma}\left(\sqrt{h + g}, \sqrt{g - h}, g\right)}}{\sqrt[3]{a}}\\
\end{array}
\end{array}
if g < -3.6500000000000002e152Initial program 1.5%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f643.6
Applied rewrites3.6%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6464.0
Applied rewrites64.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.0
Applied rewrites64.0%
if -3.6500000000000002e152 < g < -4.7999999999999998e-138Initial program 77.0%
Applied rewrites77.7%
Applied rewrites97.7%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites97.7%
if -4.7999999999999998e-138 < g < 1.1999999999999999e-264Initial program 42.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6415.8
Applied rewrites15.8%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6474.3
Applied rewrites74.3%
Applied rewrites74.4%
Applied rewrites75.4%
if 1.1999999999999999e-264 < g Initial program 44.7%
Applied rewrites44.7%
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.f6446.3
Applied rewrites46.3%
Applied rewrites96.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
lower-/.f6496.2
Applied rewrites96.2%
Final simplification86.9%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (/ (- g) a))))
(if (<= g -3.65e+152)
(+ t_0 (cbrt (* -0.25 (* (/ h g) (/ h a)))))
(if (<= g -4.8e-138)
(+
(pow
(* (cbrt (/ -1.0 (- (sqrt (* (+ h g) (- g h))) g))) (cbrt (* -2.0 a)))
-1.0)
(cbrt (/ (- (- g) (- g)) (* a 2.0))))
(if (<= g 1.2e-264)
(+ (/ (cbrt (* (* -0.25 (/ h g)) h)) (cbrt a)) t_0)
(fma
(cbrt (/ 0.5 a))
(cbrt (- (fma (sqrt (+ h g)) (sqrt (- g h)) g)))
(cbrt (/ (/ (- g g) -2.0) a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt((-g / a));
double tmp;
if (g <= -3.65e+152) {
tmp = t_0 + cbrt((-0.25 * ((h / g) * (h / a))));
} else if (g <= -4.8e-138) {
tmp = pow((cbrt((-1.0 / (sqrt(((h + g) * (g - h))) - g))) * cbrt((-2.0 * a))), -1.0) + cbrt(((-g - -g) / (a * 2.0)));
} else if (g <= 1.2e-264) {
tmp = (cbrt(((-0.25 * (h / g)) * h)) / cbrt(a)) + t_0;
} else {
tmp = fma(cbrt((0.5 / a)), cbrt(-fma(sqrt((h + g)), sqrt((g - h)), g)), cbrt((((g - g) / -2.0) / a)));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (g <= -3.65e+152) tmp = Float64(t_0 + cbrt(Float64(-0.25 * Float64(Float64(h / g) * Float64(h / a))))); elseif (g <= -4.8e-138) tmp = Float64((Float64(cbrt(Float64(-1.0 / Float64(sqrt(Float64(Float64(h + g) * Float64(g - h))) - g))) * cbrt(Float64(-2.0 * a))) ^ -1.0) + cbrt(Float64(Float64(Float64(-g) - Float64(-g)) / Float64(a * 2.0)))); elseif (g <= 1.2e-264) tmp = Float64(Float64(cbrt(Float64(Float64(-0.25 * Float64(h / g)) * h)) / cbrt(a)) + t_0); else tmp = fma(cbrt(Float64(0.5 / a)), cbrt(Float64(-fma(sqrt(Float64(h + g)), sqrt(Float64(g - h)), g))), cbrt(Float64(Float64(Float64(g - g) / -2.0) / a))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -3.65e+152], N[(t$95$0 + N[Power[N[(-0.25 * N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, -4.8e-138], N[(N[Power[N[(N[Power[N[(-1.0 / N[(N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] + N[Power[N[(N[((-g) - (-g)), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.2e-264], N[(N[(N[Power[N[(N[(-0.25 * N[(h / g), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[(-N[(N[Sqrt[N[(h + g), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(g - h), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision]), 1/3], $MachinePrecision] + N[Power[N[(N[(N[(g - g), $MachinePrecision] / -2.0), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;g \leq -3.65 \cdot 10^{+152}:\\
\;\;\;\;t\_0 + \sqrt[3]{-0.25 \cdot \left(\frac{h}{g} \cdot \frac{h}{a}\right)}\\
\mathbf{elif}\;g \leq -4.8 \cdot 10^{-138}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{-1}{\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g}} \cdot \sqrt[3]{-2 \cdot a}\right)}^{-1} + \sqrt[3]{\frac{\left(-g\right) - \left(-g\right)}{a \cdot 2}}\\
\mathbf{elif}\;g \leq 1.2 \cdot 10^{-264}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-0.25 \cdot \frac{h}{g}\right) \cdot h}}{\sqrt[3]{a}} + t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{0.5}{a}}, \sqrt[3]{-\mathsf{fma}\left(\sqrt{h + g}, \sqrt{g - h}, g\right)}, \sqrt[3]{\frac{\frac{g - g}{-2}}{a}}\right)\\
\end{array}
\end{array}
if g < -3.6500000000000002e152Initial program 1.5%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f643.6
Applied rewrites3.6%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6464.0
Applied rewrites64.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.0
Applied rewrites64.0%
if -3.6500000000000002e152 < g < -4.7999999999999998e-138Initial program 77.0%
Applied rewrites77.7%
Applied rewrites97.7%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites97.7%
if -4.7999999999999998e-138 < g < 1.1999999999999999e-264Initial program 42.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6415.8
Applied rewrites15.8%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6474.3
Applied rewrites74.3%
Applied rewrites74.4%
Applied rewrites75.4%
if 1.1999999999999999e-264 < g Initial program 44.7%
Applied rewrites44.7%
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.f6446.3
Applied rewrites46.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
*-lft-identityN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
lower-*.f6446.3
lift--.f64N/A
lift--.f64N/A
Applied rewrites68.8%
Applied rewrites96.1%
Final simplification86.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (/ 0.5 a))) (t_1 (cbrt (/ (- g) a))))
(if (<= g -2.15e+151)
(+ t_1 (cbrt (* -0.25 (* (/ h g) (/ h a)))))
(if (<= g -4.8e-138)
(fma
t_0
(cbrt (- (sqrt (* (+ h g) (- g h))) g))
(cbrt (* (- (- g) (- g)) (/ 0.5 a))))
(if (<= g 1.2e-264)
(+ (/ (cbrt (* (* -0.25 (/ h g)) h)) (cbrt a)) t_1)
(fma
t_0
(cbrt (- (fma (sqrt (+ h g)) (sqrt (- g h)) g)))
(cbrt (/ (/ (- g g) -2.0) a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt((0.5 / a));
double t_1 = cbrt((-g / a));
double tmp;
if (g <= -2.15e+151) {
tmp = t_1 + cbrt((-0.25 * ((h / g) * (h / a))));
} else if (g <= -4.8e-138) {
tmp = fma(t_0, cbrt((sqrt(((h + g) * (g - h))) - g)), cbrt(((-g - -g) * (0.5 / a))));
} else if (g <= 1.2e-264) {
tmp = (cbrt(((-0.25 * (h / g)) * h)) / cbrt(a)) + t_1;
} else {
tmp = fma(t_0, cbrt(-fma(sqrt((h + g)), sqrt((g - h)), g)), cbrt((((g - g) / -2.0) / a)));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(0.5 / a)) t_1 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (g <= -2.15e+151) tmp = Float64(t_1 + cbrt(Float64(-0.25 * Float64(Float64(h / g) * Float64(h / a))))); elseif (g <= -4.8e-138) tmp = fma(t_0, cbrt(Float64(sqrt(Float64(Float64(h + g) * Float64(g - h))) - g)), cbrt(Float64(Float64(Float64(-g) - Float64(-g)) * Float64(0.5 / a)))); elseif (g <= 1.2e-264) tmp = Float64(Float64(cbrt(Float64(Float64(-0.25 * Float64(h / g)) * h)) / cbrt(a)) + t_1); else tmp = fma(t_0, cbrt(Float64(-fma(sqrt(Float64(h + g)), sqrt(Float64(g - h)), g))), cbrt(Float64(Float64(Float64(g - g) / -2.0) / a))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -2.15e+151], N[(t$95$1 + N[Power[N[(-0.25 * N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, -4.8e-138], N[(t$95$0 * N[Power[N[(N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[((-g) - (-g)), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.2e-264], N[(N[(N[Power[N[(N[(-0.25 * N[(h / g), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(t$95$0 * N[Power[(-N[(N[Sqrt[N[(h + g), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(g - h), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision]), 1/3], $MachinePrecision] + N[Power[N[(N[(N[(g - g), $MachinePrecision] / -2.0), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a}}\\
t_1 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;g \leq -2.15 \cdot 10^{+151}:\\
\;\;\;\;t\_1 + \sqrt[3]{-0.25 \cdot \left(\frac{h}{g} \cdot \frac{h}{a}\right)}\\
\mathbf{elif}\;g \leq -4.8 \cdot 10^{-138}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g}, \sqrt[3]{\left(\left(-g\right) - \left(-g\right)\right) \cdot \frac{0.5}{a}}\right)\\
\mathbf{elif}\;g \leq 1.2 \cdot 10^{-264}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-0.25 \cdot \frac{h}{g}\right) \cdot h}}{\sqrt[3]{a}} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \sqrt[3]{-\mathsf{fma}\left(\sqrt{h + g}, \sqrt{g - h}, g\right)}, \sqrt[3]{\frac{\frac{g - g}{-2}}{a}}\right)\\
\end{array}
\end{array}
if g < -2.14999999999999991e151Initial program 3.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6464.5
Applied rewrites64.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.5
Applied rewrites64.5%
if -2.14999999999999991e151 < g < -4.7999999999999998e-138Initial program 76.6%
Applied rewrites77.3%
Applied rewrites97.6%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f6497.6
Applied rewrites97.6%
Applied rewrites97.5%
if -4.7999999999999998e-138 < g < 1.1999999999999999e-264Initial program 42.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6415.8
Applied rewrites15.8%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6474.3
Applied rewrites74.3%
Applied rewrites74.4%
Applied rewrites75.4%
if 1.1999999999999999e-264 < g Initial program 44.7%
Applied rewrites44.7%
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.f6446.3
Applied rewrites46.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
*-lft-identityN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
lower-*.f6446.3
lift--.f64N/A
lift--.f64N/A
Applied rewrites68.8%
Applied rewrites96.1%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (/ (- g) a))))
(if (<= g -2.15e+151)
(+ t_0 (cbrt (* -0.25 (* (/ h g) (/ h a)))))
(if (<= g -4.8e-138)
(fma
(cbrt (/ 0.5 a))
(cbrt (- (sqrt (* (+ h g) (- g h))) g))
(cbrt (* (- (- g) (- g)) (/ 0.5 a))))
(+ (/ (cbrt (* (* -0.25 (/ h g)) h)) (cbrt a)) t_0)))))
double code(double g, double h, double a) {
double t_0 = cbrt((-g / a));
double tmp;
if (g <= -2.15e+151) {
tmp = t_0 + cbrt((-0.25 * ((h / g) * (h / a))));
} else if (g <= -4.8e-138) {
tmp = fma(cbrt((0.5 / a)), cbrt((sqrt(((h + g) * (g - h))) - g)), cbrt(((-g - -g) * (0.5 / a))));
} else {
tmp = (cbrt(((-0.25 * (h / g)) * h)) / cbrt(a)) + t_0;
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (g <= -2.15e+151) tmp = Float64(t_0 + cbrt(Float64(-0.25 * Float64(Float64(h / g) * Float64(h / a))))); elseif (g <= -4.8e-138) tmp = fma(cbrt(Float64(0.5 / a)), cbrt(Float64(sqrt(Float64(Float64(h + g) * Float64(g - h))) - g)), cbrt(Float64(Float64(Float64(-g) - Float64(-g)) * Float64(0.5 / a)))); else tmp = Float64(Float64(cbrt(Float64(Float64(-0.25 * Float64(h / g)) * h)) / cbrt(a)) + t_0); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -2.15e+151], N[(t$95$0 + N[Power[N[(-0.25 * N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, -4.8e-138], N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[((-g) - (-g)), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(N[(-0.25 * N[(h / g), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;g \leq -2.15 \cdot 10^{+151}:\\
\;\;\;\;t\_0 + \sqrt[3]{-0.25 \cdot \left(\frac{h}{g} \cdot \frac{h}{a}\right)}\\
\mathbf{elif}\;g \leq -4.8 \cdot 10^{-138}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{0.5}{a}}, \sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g}, \sqrt[3]{\left(\left(-g\right) - \left(-g\right)\right) \cdot \frac{0.5}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-0.25 \cdot \frac{h}{g}\right) \cdot h}}{\sqrt[3]{a}} + t\_0\\
\end{array}
\end{array}
if g < -2.14999999999999991e151Initial program 3.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6464.5
Applied rewrites64.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.5
Applied rewrites64.5%
if -2.14999999999999991e151 < g < -4.7999999999999998e-138Initial program 76.6%
Applied rewrites77.3%
Applied rewrites97.6%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f6497.6
Applied rewrites97.6%
Applied rewrites97.5%
if -4.7999999999999998e-138 < g Initial program 44.4%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6441.0
Applied rewrites41.0%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6470.1
Applied rewrites70.1%
Applied rewrites70.1%
Applied rewrites70.4%
(FPCore (g h a) :precision binary64 (+ (/ (cbrt (* (* -0.25 (/ h g)) h)) (cbrt a)) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return (cbrt(((-0.25 * (h / g)) * h)) / cbrt(a)) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return (Math.cbrt(((-0.25 * (h / g)) * h)) / Math.cbrt(a)) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(Float64(-0.25 * Float64(h / g)) * h)) / cbrt(a)) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[(N[Power[N[(N[(-0.25 * N[(h / g), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\left(-0.25 \cdot \frac{h}{g}\right) \cdot h}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 40.4%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6426.2
Applied rewrites26.2%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6470.2
Applied rewrites70.2%
Applied rewrites70.2%
Applied rewrites70.4%
(FPCore (g h a) :precision binary64 (+ (* (cbrt (/ h a)) (cbrt (* (/ h g) -0.25))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return (cbrt((h / a)) * cbrt(((h / g) * -0.25))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return (Math.cbrt((h / a)) * Math.cbrt(((h / g) * -0.25))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(h / a)) * cbrt(Float64(Float64(h / g) * -0.25))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[(N[Power[N[(h / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(N[(h / g), $MachinePrecision] * -0.25), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{h}{a}} \cdot \sqrt[3]{\frac{h}{g} \cdot -0.25} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 40.4%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6426.2
Applied rewrites26.2%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6470.2
Applied rewrites70.2%
Applied rewrites70.2%
(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 40.4%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6426.2
Applied rewrites26.2%
Taylor expanded in g around -inf
lower-*.f6414.5
Applied rewrites14.5%
Final simplification14.5%
(FPCore (g h a) :precision binary64 (+ (cbrt (/ (- g) a)) (cbrt (* -0.25 (* (/ h g) (/ h a))))))
double code(double g, double h, double a) {
return cbrt((-g / a)) + cbrt((-0.25 * ((h / g) * (h / a))));
}
public static double code(double g, double h, double a) {
return Math.cbrt((-g / a)) + Math.cbrt((-0.25 * ((h / g) * (h / a))));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(Float64(-0.25 * Float64(Float64(h / g) * Float64(h / a))))) end
code[g_, h_, a_] := N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(-0.25 * N[(N[(h / g), $MachinePrecision] * N[(h / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{-0.25 \cdot \left(\frac{h}{g} \cdot \frac{h}{a}\right)}
\end{array}
Initial program 40.4%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6426.2
Applied rewrites26.2%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6470.2
Applied rewrites70.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6470.2
Applied rewrites70.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 40.4%
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
unpow-prod-downN/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
pow1/3N/A
lower-cbrt.f6445.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.4
Applied rewrites45.4%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
lower-cbrt.f643.0
Applied rewrites3.0%
Applied rewrites3.0%
herbie shell --seed 2024309
(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))))))))