
(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 5 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 (sqrt (- (pow g 2.0) (pow h 2.0))))
(t_1 (sqrt (- (* g g) (* h h)))))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_1 g)))
(cbrt (* (+ g t_1) (/ -1.0 (* 2.0 a)))))
4e-100)
(+
(/ (cbrt (* 0.5 (- t_0 g))) (cbrt a))
(* (cbrt (/ -0.5 a)) (cbrt (+ g t_0))))
(+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ (- g) a))))))
double code(double g, double h, double a) {
double t_0 = sqrt((pow(g, 2.0) - pow(h, 2.0)));
double t_1 = sqrt(((g * g) - (h * h)));
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 4e-100) {
tmp = (cbrt((0.5 * (t_0 - g))) / cbrt(a)) + (cbrt((-0.5 / a)) * cbrt((g + t_0)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) + cbrt((-g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt((Math.pow(g, 2.0) - Math.pow(h, 2.0)));
double t_1 = Math.sqrt(((g * g) - (h * h)));
double tmp;
if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + Math.cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 4e-100) {
tmp = (Math.cbrt((0.5 * (t_0 - g))) / Math.cbrt(a)) + (Math.cbrt((-0.5 / a)) * Math.cbrt((g + t_0)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64((g ^ 2.0) - (h ^ 2.0))) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_1 - g))) + cbrt(Float64(Float64(g + t_1) * Float64(-1.0 / Float64(2.0 * a))))) <= 4e-100) tmp = Float64(Float64(cbrt(Float64(0.5 * Float64(t_0 - g))) / cbrt(a)) + Float64(cbrt(Float64(-0.5 / a)) * cbrt(Float64(g + t_0)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-g) / a))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[g, 2.0], $MachinePrecision] - N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$1), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 4e-100], N[(N[(N[Power[N[(0.5 * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g + t$95$0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{g}^{2} - {h}^{2}}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_1 - g\right)} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-1}{2 \cdot a}} \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(t_0 - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.0000000000000001e-100Initial program 74.3%
Simplified74.3%
*-commutative74.3%
cbrt-prod80.5%
pow280.5%
pow280.5%
Applied egg-rr80.5%
associate-*l/80.5%
cbrt-div90.1%
pow290.1%
pow290.1%
Applied egg-rr90.1%
if 4.0000000000000001e-100 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 28.8%
Simplified28.8%
Taylor expanded in g around inf 13.3%
Taylor expanded in g around inf 75.3%
associate-*r/75.3%
neg-mul-175.3%
Simplified75.3%
Final simplification80.1%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (+ g t_0)))
(if (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- t_0 g)))
(cbrt (* t_1 (/ -1.0 (* 2.0 a)))))
4e-100)
(+
(/ (cbrt (* 0.5 (- (sqrt (- (pow g 2.0) (pow h 2.0))) g))) (cbrt a))
(cbrt (* (/ -0.5 a) t_1)))
(+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ (- g) a))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = g + t_0;
double tmp;
if ((cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + cbrt((t_1 * (-1.0 / (2.0 * a))))) <= 4e-100) {
tmp = (cbrt((0.5 * (sqrt((pow(g, 2.0) - pow(h, 2.0))) - g))) / cbrt(a)) + cbrt(((-0.5 / a) * t_1));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) + cbrt((-g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = g + t_0;
double tmp;
if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + Math.cbrt((t_1 * (-1.0 / (2.0 * a))))) <= 4e-100) {
tmp = (Math.cbrt((0.5 * (Math.sqrt((Math.pow(g, 2.0) - Math.pow(h, 2.0))) - g))) / Math.cbrt(a)) + Math.cbrt(((-0.5 / a) * t_1));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = Float64(g + t_0) tmp = 0.0 if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_0 - g))) + cbrt(Float64(t_1 * Float64(-1.0 / Float64(2.0 * a))))) <= 4e-100) tmp = Float64(Float64(cbrt(Float64(0.5 * Float64(sqrt(Float64((g ^ 2.0) - (h ^ 2.0))) - g))) / cbrt(a)) + cbrt(Float64(Float64(-0.5 / a) * t_1))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-g) / a))); 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[(g + t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$1 * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 4e-100], N[(N[(N[Power[N[(0.5 * N[(N[Sqrt[N[(N[Power[g, 2.0], $MachinePrecision] - N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * t$95$1), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := g + t_0\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_0 - g\right)} + \sqrt[3]{t_1 \cdot \frac{-1}{2 \cdot a}} \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(\sqrt{{g}^{2} - {h}^{2}} - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-0.5}{a} \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.0000000000000001e-100Initial program 74.3%
Simplified74.3%
associate-*l/80.5%
cbrt-div90.1%
pow290.1%
pow290.1%
Applied egg-rr85.3%
if 4.0000000000000001e-100 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 28.8%
Simplified28.8%
Taylor expanded in g around inf 13.3%
Taylor expanded in g around inf 75.3%
associate-*r/75.3%
neg-mul-175.3%
Simplified75.3%
Final simplification78.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ 0.5 a) (- g g)))))
(if (<= g 1.9e-157)
(+ t_0 (cbrt (* (/ -0.5 a) (+ g g))))
(if (<= g 1.25e+153)
(+
(* (cbrt (/ -0.5 a)) (cbrt (+ g (sqrt (- (pow g 2.0) (pow h 2.0))))))
(cbrt (* (- (sqrt (- (* g g) (* h h))) g) (/ 0.5 a))))
(+ t_0 (cbrt (/ (- g) a)))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((0.5 / a) * (g - g)));
double tmp;
if (g <= 1.9e-157) {
tmp = t_0 + cbrt(((-0.5 / a) * (g + g)));
} else if (g <= 1.25e+153) {
tmp = (cbrt((-0.5 / a)) * cbrt((g + sqrt((pow(g, 2.0) - pow(h, 2.0)))))) + cbrt(((sqrt(((g * g) - (h * h))) - g) * (0.5 / a)));
} else {
tmp = t_0 + cbrt((-g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((0.5 / a) * (g - g)));
double tmp;
if (g <= 1.9e-157) {
tmp = t_0 + Math.cbrt(((-0.5 / a) * (g + g)));
} else if (g <= 1.25e+153) {
tmp = (Math.cbrt((-0.5 / a)) * Math.cbrt((g + Math.sqrt((Math.pow(g, 2.0) - Math.pow(h, 2.0)))))) + Math.cbrt(((Math.sqrt(((g * g) - (h * h))) - g) * (0.5 / a)));
} else {
tmp = t_0 + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) tmp = 0.0 if (g <= 1.9e-157) tmp = Float64(t_0 + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); elseif (g <= 1.25e+153) tmp = Float64(Float64(cbrt(Float64(-0.5 / a)) * cbrt(Float64(g + sqrt(Float64((g ^ 2.0) - (h ^ 2.0)))))) + cbrt(Float64(Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) - g) * Float64(0.5 / a)))); else tmp = Float64(t_0 + cbrt(Float64(Float64(-g) / a))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, 1.9e-157], N[(t$95$0 + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.25e+153], N[(N[(N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g + N[Sqrt[N[(N[Power[g, 2.0], $MachinePrecision] - N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\
\mathbf{if}\;g \leq 1.9 \cdot 10^{-157}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\mathbf{elif}\;g \leq 1.25 \cdot 10^{+153}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \sqrt{{g}^{2} - {h}^{2}}} + \sqrt[3]{\left(\sqrt{g \cdot g - h \cdot h} - g\right) \cdot \frac{0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if g < 1.9000000000000001e-157Initial program 46.0%
Simplified46.0%
Taylor expanded in g around inf 4.0%
Taylor expanded in g around inf 78.6%
if 1.9000000000000001e-157 < g < 1.25000000000000005e153Initial program 83.2%
Simplified83.2%
*-commutative83.2%
cbrt-prod96.0%
pow296.0%
pow296.0%
Applied egg-rr96.0%
if 1.25000000000000005e153 < g Initial program 3.0%
Simplified3.0%
Taylor expanded in g around inf 6.1%
Taylor expanded in g around inf 64.0%
associate-*r/64.0%
neg-mul-164.0%
Simplified64.0%
Final simplification78.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (* (/ -0.5 a) (+ g g)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt(((-0.5 / a) * (g + g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt(((-0.5 / a) * (g + g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}
\end{array}
Initial program 43.4%
Simplified43.4%
Taylor expanded in g around inf 21.8%
Taylor expanded in g around inf 75.6%
Final simplification75.6%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ (- g) a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt((-g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((-g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-g) / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}
\end{array}
Initial program 43.4%
Simplified43.4%
Taylor expanded in g around inf 21.8%
Taylor expanded in g around inf 75.6%
associate-*r/75.6%
neg-mul-175.6%
Simplified75.6%
Final simplification75.6%
herbie shell --seed 2024011
(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))))))))