
(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 (cbrt (* 2.0 a))) (t_1 (* (/ h g) (* -0.5 h))))
(if (<= g 1.6e+168)
(fma (cbrt (/ 0.5 a)) (- (cbrt (* 2.0 g))) (cbrt (* t_1 (/ 0.5 a))))
(/
(fma
(cbrt (- (fma (sqrt (- g h)) (sqrt (+ h g)) g)))
t_0
(* (cbrt t_1) t_0))
(* t_0 t_0)))))
double code(double g, double h, double a) {
double t_0 = cbrt((2.0 * a));
double t_1 = (h / g) * (-0.5 * h);
double tmp;
if (g <= 1.6e+168) {
tmp = fma(cbrt((0.5 / a)), -cbrt((2.0 * g)), cbrt((t_1 * (0.5 / a))));
} else {
tmp = fma(cbrt(-fma(sqrt((g - h)), sqrt((h + g)), g)), t_0, (cbrt(t_1) * t_0)) / (t_0 * t_0);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(2.0 * a)) t_1 = Float64(Float64(h / g) * Float64(-0.5 * h)) tmp = 0.0 if (g <= 1.6e+168) tmp = fma(cbrt(Float64(0.5 / a)), Float64(-cbrt(Float64(2.0 * g))), cbrt(Float64(t_1 * Float64(0.5 / a)))); else tmp = Float64(fma(cbrt(Float64(-fma(sqrt(Float64(g - h)), sqrt(Float64(h + g)), g))), t_0, Float64(cbrt(t_1) * t_0)) / Float64(t_0 * t_0)); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[(h / g), $MachinePrecision] * N[(-0.5 * h), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[g, 1.6e+168], N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * (-N[Power[N[(2.0 * g), $MachinePrecision], 1/3], $MachinePrecision]) + N[Power[N[(t$95$1 * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[(-N[(N[Sqrt[N[(g - h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(h + g), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision]), 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[t$95$1, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{2 \cdot a}\\
t_1 := \frac{h}{g} \cdot \left(-0.5 \cdot h\right)\\
\mathbf{if}\;g \leq 1.6 \cdot 10^{+168}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{0.5}{a}}, -\sqrt[3]{2 \cdot g}, \sqrt[3]{t\_1 \cdot \frac{0.5}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-\mathsf{fma}\left(\sqrt{g - h}, \sqrt{h + g}, g\right)}, t\_0, \sqrt[3]{t\_1} \cdot t\_0\right)}{t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if g < 1.6000000000000001e168Initial program 60.4%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
*-lft-identityN/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6435.8
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lower-*.f6435.8
Applied rewrites35.8%
Applied rewrites39.5%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-cbrt.f64N/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
lower-*.f6496.2
Applied rewrites96.2%
if 1.6000000000000001e168 < g Initial program 0.0%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f642.8
Applied rewrites2.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
*-lft-identityN/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f642.8
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lower-*.f643.9
Applied rewrites3.9%
Applied rewrites96.2%
Final simplification96.2%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (* (/ h g) (* -0.5 h))) (t_1 (cbrt (/ 0.5 a))))
(if (<= g 3e+186)
(fma t_1 (- (cbrt (* 2.0 g))) (cbrt (* t_0 (/ 0.5 a))))
(* (+ (cbrt t_0) (cbrt (- (fma (sqrt (- g h)) (sqrt (+ h g)) g)))) t_1))))
double code(double g, double h, double a) {
double t_0 = (h / g) * (-0.5 * h);
double t_1 = cbrt((0.5 / a));
double tmp;
if (g <= 3e+186) {
tmp = fma(t_1, -cbrt((2.0 * g)), cbrt((t_0 * (0.5 / a))));
} else {
tmp = (cbrt(t_0) + cbrt(-fma(sqrt((g - h)), sqrt((h + g)), g))) * t_1;
}
return tmp;
}
function code(g, h, a) t_0 = Float64(Float64(h / g) * Float64(-0.5 * h)) t_1 = cbrt(Float64(0.5 / a)) tmp = 0.0 if (g <= 3e+186) tmp = fma(t_1, Float64(-cbrt(Float64(2.0 * g))), cbrt(Float64(t_0 * Float64(0.5 / a)))); else tmp = Float64(Float64(cbrt(t_0) + cbrt(Float64(-fma(sqrt(Float64(g - h)), sqrt(Float64(h + g)), g)))) * t_1); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[(h / g), $MachinePrecision] * N[(-0.5 * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, 3e+186], N[(t$95$1 * (-N[Power[N[(2.0 * g), $MachinePrecision], 1/3], $MachinePrecision]) + N[Power[N[(t$95$0 * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[t$95$0, 1/3], $MachinePrecision] + N[Power[(-N[(N[Sqrt[N[(g - h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(h + g), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision]), 1/3], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{h}{g} \cdot \left(-0.5 \cdot h\right)\\
t_1 := \sqrt[3]{\frac{0.5}{a}}\\
\mathbf{if}\;g \leq 3 \cdot 10^{+186}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -\sqrt[3]{2 \cdot g}, \sqrt[3]{t\_0 \cdot \frac{0.5}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{t\_0} + \sqrt[3]{-\mathsf{fma}\left(\sqrt{g - h}, \sqrt{h + g}, g\right)}\right) \cdot t\_1\\
\end{array}
\end{array}
if g < 2.99999999999999982e186Initial program 57.4%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
*-lft-identityN/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6434.1
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lower-*.f6434.2
Applied rewrites34.2%
Applied rewrites42.4%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-cbrt.f64N/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
lower-*.f6496.3
Applied rewrites96.3%
if 2.99999999999999982e186 < g Initial program 0.0%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f642.9
Applied rewrites2.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
*-lft-identityN/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f642.9
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
lower-*.f643.9
Applied rewrites3.9%
Applied rewrites95.6%
Final simplification96.1%
(FPCore (g h a) :precision binary64 (+ (/ (cbrt (- g)) (cbrt a)) (cbrt (* (* (* (/ h g) h) -0.5) (/ 1.0 (* 2.0 a))))))
double code(double g, double h, double a) {
return (cbrt(-g) / cbrt(a)) + cbrt(((((h / g) * h) * -0.5) * (1.0 / (2.0 * a))));
}
public static double code(double g, double h, double a) {
return (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(((((h / g) * h) * -0.5) * (1.0 / (2.0 * a))));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(Float64(Float64(Float64(Float64(h / g) * h) * -0.5) * Float64(1.0 / Float64(2.0 * a))))) end
code[g_, h_, a_] := N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[(N[(h / g), $MachinePrecision] * h), $MachinePrecision] * -0.5), $MachinePrecision] * N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{\left(\left(\frac{h}{g} \cdot h\right) \cdot -0.5\right) \cdot \frac{1}{2 \cdot a}}
\end{array}
Initial program 45.3%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6427.6
Applied rewrites27.6%
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
cbrt-divN/A
lower-/.f64N/A
Applied rewrites29.2%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f6486.1
Applied rewrites86.1%
Applied rewrites94.0%
Final simplification94.0%
(FPCore (g h a) :precision binary64 (if (<= h 1.35e+154) (+ (cbrt (* (/ (* h h) g) (/ -0.25 a))) (/ (cbrt (- g)) (cbrt a))) (+ (cbrt (* (* (/ h a) (/ h g)) -0.25)) (cbrt (/ (- g) a)))))
double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = cbrt((((h * h) / g) * (-0.25 / a))) + (cbrt(-g) / cbrt(a));
} else {
tmp = cbrt((((h / a) * (h / g)) * -0.25)) + cbrt((-g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = Math.cbrt((((h * h) / g) * (-0.25 / a))) + (Math.cbrt(-g) / Math.cbrt(a));
} else {
tmp = Math.cbrt((((h / a) * (h / g)) * -0.25)) + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (h <= 1.35e+154) tmp = Float64(cbrt(Float64(Float64(Float64(h * h) / g) * Float64(-0.25 / a))) + Float64(cbrt(Float64(-g)) / cbrt(a))); else tmp = Float64(cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25)) + cbrt(Float64(Float64(-g) / a))); end return tmp end
code[g_, h_, a_] := If[LessEqual[h, 1.35e+154], N[(N[Power[N[(N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision] * N[(-0.25 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{\frac{h \cdot h}{g} \cdot \frac{-0.25}{a}} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25} + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if h < 1.35000000000000003e154Initial program 49.6%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6430.2
Applied rewrites30.2%
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
cbrt-divN/A
lower-/.f64N/A
Applied rewrites31.7%
Taylor expanded in g around inf
mul-1-negN/A
lower-neg.f6493.8
Applied rewrites93.8%
Taylor expanded in g around inf
associate-*r/N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6493.8
Applied rewrites93.8%
if 1.35000000000000003e154 < h Initial program 0.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f640.0
Applied rewrites0.0%
Taylor expanded in g around inf
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
lower-cbrt.f64N/A
lower-cbrt.f6451.7
Applied rewrites51.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6451.7
Applied rewrites51.7%
Final simplification90.2%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (* (/ h a) (/ h g)) -0.25)) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt((((h / a) * (h / g)) * -0.25)) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt((((h / a) * (h / g)) * -0.25)) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25)) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 45.3%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.9
Applied rewrites29.9%
Taylor expanded in g around inf
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
lower-cbrt.f64N/A
lower-cbrt.f6476.6
Applied rewrites76.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6476.6
Applied rewrites76.6%
Final simplification76.6%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (* -2.0 g) (/ 1.0 (* 2.0 a)))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt(((-2.0 * g) * (1.0 / (2.0 * a)))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-2.0 * g) * (1.0 / (2.0 * a)))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-2.0 * g) * Float64(1.0 / Float64(2.0 * a)))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(-2.0 * g), $MachinePrecision] * N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(-2 \cdot g\right) \cdot \frac{1}{2 \cdot a}} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 45.3%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.9
Applied rewrites29.9%
Taylor expanded in g around -inf
lower-*.f6415.5
Applied rewrites15.5%
Final simplification15.5%
(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.3%
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
unpow-prod-downN/A
lower-*.f64N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-pow.f64N/A
Applied rewrites25.6%
Taylor expanded in g around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cbrt.f64N/A
*-commutativeN/A
+-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
mul0-lftN/A
mul0-lftN/A
metadata-evalN/A
distribute-rgt1-inN/A
lower-cbrt.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
lower-/.f643.0
Applied rewrites3.0%
Taylor expanded in a around 0
Applied rewrites3.0%
herbie shell --seed 2024248
(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))))))))