
(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 (* (* (/ h a) (/ h g)) -0.25))))
(if (<= g -1.35e+154)
(+ t_0 (cbrt (* (pow a -1.0) (- g))))
(if (<= g -3.4e-160)
(+
(cbrt (* (/ (* h h) g) (/ -0.25 a)))
(/ (cbrt (- (sqrt (* (+ h g) (- g h))) g)) (cbrt (* a 2.0))))
(+ (cbrt (/ (- g) a)) t_0)))))
double code(double g, double h, double a) {
double t_0 = cbrt((((h / a) * (h / g)) * -0.25));
double tmp;
if (g <= -1.35e+154) {
tmp = t_0 + cbrt((pow(a, -1.0) * -g));
} else if (g <= -3.4e-160) {
tmp = cbrt((((h * h) / g) * (-0.25 / a))) + (cbrt((sqrt(((h + g) * (g - h))) - g)) / cbrt((a * 2.0)));
} else {
tmp = cbrt((-g / a)) + t_0;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt((((h / a) * (h / g)) * -0.25));
double tmp;
if (g <= -1.35e+154) {
tmp = t_0 + Math.cbrt((Math.pow(a, -1.0) * -g));
} else if (g <= -3.4e-160) {
tmp = Math.cbrt((((h * h) / g) * (-0.25 / a))) + (Math.cbrt((Math.sqrt(((h + g) * (g - h))) - g)) / Math.cbrt((a * 2.0)));
} else {
tmp = Math.cbrt((-g / a)) + t_0;
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25)) tmp = 0.0 if (g <= -1.35e+154) tmp = Float64(t_0 + cbrt(Float64((a ^ -1.0) * Float64(-g)))); elseif (g <= -3.4e-160) tmp = Float64(cbrt(Float64(Float64(Float64(h * h) / g) * Float64(-0.25 / a))) + Float64(cbrt(Float64(sqrt(Float64(Float64(h + g) * Float64(g - h))) - g)) / cbrt(Float64(a * 2.0)))); else tmp = Float64(cbrt(Float64(Float64(-g) / a)) + t_0); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -1.35e+154], N[(t$95$0 + N[Power[N[(N[Power[a, -1.0], $MachinePrecision] * (-g)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, -3.4e-160], N[(N[Power[N[(N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision] * N[(-0.25 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25}\\
\mathbf{if}\;g \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_0 + \sqrt[3]{{a}^{-1} \cdot \left(-g\right)}\\
\mathbf{elif}\;g \leq -3.4 \cdot 10^{-160}:\\
\;\;\;\;\sqrt[3]{\frac{h \cdot h}{g} \cdot \frac{-0.25}{a}} + \frac{\sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g}}{\sqrt[3]{a \cdot 2}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-g}{a}} + t\_0\\
\end{array}
\end{array}
if g < -1.35000000000000003e154Initial program 0.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f643.2
Applied rewrites3.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.f6463.6
Applied rewrites63.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6463.6
Applied rewrites63.6%
Applied rewrites63.7%
if -1.35000000000000003e154 < g < -3.40000000000000021e-160Initial program 83.9%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
cbrt-divN/A
*-lft-identityN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites94.5%
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-*.f6497.2
Applied rewrites97.2%
if -3.40000000000000021e-160 < g Initial program 48.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6448.1
Applied rewrites48.1%
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.f6478.9
Applied rewrites78.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.9
Applied rewrites78.9%
Final simplification81.3%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (* (+ h g) (- g h)))) (t_1 (cbrt (* a 2.0))))
(if (<= (/ 1.0 (* a 2.0)) -4e+273)
(+ (/ (cbrt (- (- g) t_0)) t_1) (/ (cbrt (- t_0 g)) t_1))
(+ (cbrt (* (* (/ h a) (/ h g)) -0.25)) (cbrt (* (pow a -1.0) (- g)))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((h + g) * (g - h)));
double t_1 = cbrt((a * 2.0));
double tmp;
if ((1.0 / (a * 2.0)) <= -4e+273) {
tmp = (cbrt((-g - t_0)) / t_1) + (cbrt((t_0 - g)) / t_1);
} else {
tmp = cbrt((((h / a) * (h / g)) * -0.25)) + cbrt((pow(a, -1.0) * -g));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((h + g) * (g - h)));
double t_1 = Math.cbrt((a * 2.0));
double tmp;
if ((1.0 / (a * 2.0)) <= -4e+273) {
tmp = (Math.cbrt((-g - t_0)) / t_1) + (Math.cbrt((t_0 - g)) / t_1);
} else {
tmp = Math.cbrt((((h / a) * (h / g)) * -0.25)) + Math.cbrt((Math.pow(a, -1.0) * -g));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(h + g) * Float64(g - h))) t_1 = cbrt(Float64(a * 2.0)) tmp = 0.0 if (Float64(1.0 / Float64(a * 2.0)) <= -4e+273) tmp = Float64(Float64(cbrt(Float64(Float64(-g) - t_0)) / t_1) + Float64(cbrt(Float64(t_0 - g)) / t_1)); else tmp = Float64(cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25)) + cbrt(Float64((a ^ -1.0) * Float64(-g)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], -4e+273], N[(N[(N[Power[N[((-g) - t$95$0), $MachinePrecision], 1/3], $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[Power[N[(t$95$0 - g), $MachinePrecision], 1/3], $MachinePrecision] / t$95$1), $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[(N[Power[a, -1.0], $MachinePrecision] * (-g)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\\
t_1 := \sqrt[3]{a \cdot 2}\\
\mathbf{if}\;\frac{1}{a \cdot 2} \leq -4 \cdot 10^{+273}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-g\right) - t\_0}}{t\_1} + \frac{\sqrt[3]{t\_0 - g}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25} + \sqrt[3]{{a}^{-1} \cdot \left(-g\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < -3.99999999999999978e273Initial program 18.9%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
cbrt-divN/A
*-lft-identityN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites42.5%
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
cbrt-divN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cbrt.f64N/A
lower-/.f64N/A
Applied rewrites65.8%
if -3.99999999999999978e273 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 50.7%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6431.9
Applied rewrites31.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.f6480.8
Applied rewrites80.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6480.8
Applied rewrites80.8%
Applied rewrites80.8%
Final simplification80.1%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (* (/ h a) (/ h g)) -0.25)) (cbrt (* (pow a -1.0) (- g)))))
double code(double g, double h, double a) {
return cbrt((((h / a) * (h / g)) * -0.25)) + cbrt((pow(a, -1.0) * -g));
}
public static double code(double g, double h, double a) {
return Math.cbrt((((h / a) * (h / g)) * -0.25)) + Math.cbrt((Math.pow(a, -1.0) * -g));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25)) + cbrt(Float64((a ^ -1.0) * Float64(-g)))) 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[(N[Power[a, -1.0], $MachinePrecision] * (-g)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25} + \sqrt[3]{{a}^{-1} \cdot \left(-g\right)}
\end{array}
Initial program 49.2%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6430.7
Applied rewrites30.7%
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.f6478.0
Applied rewrites78.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.0
Applied rewrites78.0%
Applied rewrites78.0%
Final simplification78.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (+ (cbrt (* (* -2.0 g) (/ 1.0 (* a 2.0)))) (cbrt (/ (- g) a)))))
(if (<= g -3.5e-160)
t_0
(if (<= g 5.6e+151)
(* (cbrt -0.5) (cbrt (/ (+ (sqrt (- (* g g) (* h h))) g) a)))
t_0))))
double code(double g, double h, double a) {
double t_0 = cbrt(((-2.0 * g) * (1.0 / (a * 2.0)))) + cbrt((-g / a));
double tmp;
if (g <= -3.5e-160) {
tmp = t_0;
} else if (g <= 5.6e+151) {
tmp = cbrt(-0.5) * cbrt(((sqrt(((g * g) - (h * h))) + g) / a));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((-2.0 * g) * (1.0 / (a * 2.0)))) + Math.cbrt((-g / a));
double tmp;
if (g <= -3.5e-160) {
tmp = t_0;
} else if (g <= 5.6e+151) {
tmp = Math.cbrt(-0.5) * Math.cbrt(((Math.sqrt(((g * g) - (h * h))) + g) / a));
} else {
tmp = t_0;
}
return tmp;
}
function code(g, h, a) t_0 = Float64(cbrt(Float64(Float64(-2.0 * g) * Float64(1.0 / Float64(a * 2.0)))) + cbrt(Float64(Float64(-g) / a))) tmp = 0.0 if (g <= -3.5e-160) tmp = t_0; elseif (g <= 5.6e+151) tmp = Float64(cbrt(-0.5) * cbrt(Float64(Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) + g) / a))); else tmp = t_0; end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[N[(N[(-2.0 * g), $MachinePrecision] * N[(1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[g, -3.5e-160], t$95$0, If[LessEqual[g, 5.6e+151], N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[N[(N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\left(-2 \cdot g\right) \cdot \frac{1}{a \cdot 2}} + \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;g \leq -3.5 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;g \leq 5.6 \cdot 10^{+151}:\\
\;\;\;\;\sqrt[3]{-0.5} \cdot \sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} + g}{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if g < -3.5000000000000003e-160 or 5.59999999999999975e151 < g Initial program 36.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f648.2
Applied rewrites8.2%
Taylor expanded in g around -inf
lower-*.f6415.0
Applied rewrites15.0%
if -3.5000000000000003e-160 < g < 5.59999999999999975e151Initial program 75.3%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6475.3
Applied rewrites75.3%
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
sub-negN/A
lift--.f64N/A
lift-/.f64N/A
Applied rewrites35.2%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f6435.2
Applied rewrites35.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-cbrt.f6475.5
Applied rewrites75.5%
Final simplification35.3%
(FPCore (g h a) :precision binary64 (+ (cbrt (/ (- g) a)) (cbrt (* (* (/ h a) (/ h g)) -0.25))))
double code(double g, double h, double a) {
return cbrt((-g / a)) + cbrt((((h / a) * (h / g)) * -0.25));
}
public static double code(double g, double h, double a) {
return Math.cbrt((-g / a)) + Math.cbrt((((h / a) * (h / g)) * -0.25));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-g) / a)) + cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25))) end
code[g_, h_, a_] := N[(N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-g}{a}} + \sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25}
\end{array}
Initial program 49.2%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6430.7
Applied rewrites30.7%
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.f6478.0
Applied rewrites78.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.0
Applied rewrites78.0%
Final simplification78.0%
(FPCore (g h a) :precision binary64 (* (cbrt -0.5) (cbrt (/ (+ (sqrt (- (* g g) (* h h))) g) a))))
double code(double g, double h, double a) {
return cbrt(-0.5) * cbrt(((sqrt(((g * g) - (h * h))) + g) / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-0.5) * Math.cbrt(((Math.sqrt(((g * g) - (h * h))) + g) / a));
}
function code(g, h, a) return Float64(cbrt(-0.5) * cbrt(Float64(Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) + g) / a))) end
code[g_, h_, a_] := N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[N[(N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-0.5} \cdot \sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} + g}{a}}
\end{array}
Initial program 49.2%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6430.7
Applied rewrites30.7%
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
sub-negN/A
lift--.f64N/A
lift-/.f64N/A
Applied rewrites14.5%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f6414.5
Applied rewrites14.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-cbrt.f6426.9
Applied rewrites26.9%
Final simplification26.9%
(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 49.2%
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
Applied rewrites52.7%
Taylor expanded in g around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
unpow2N/A
rem-square-sqrtN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-cbrt.f643.0
Applied rewrites3.0%
Taylor expanded in a around 0
Applied rewrites3.0%
herbie shell --seed 2024242
(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))))))))