
(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 (/ (cbrt (+ g g)) (cbrt (* a -2.0))))
double code(double g, double h, double a) {
return cbrt((g + g)) / cbrt((a * -2.0));
}
public static double code(double g, double h, double a) {
return Math.cbrt((g + g)) / Math.cbrt((a * -2.0));
}
function code(g, h, a) return Float64(cbrt(Float64(g + g)) / cbrt(Float64(a * -2.0))) end
code[g_, h_, a_] := N[(N[Power[N[(g + g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g + g}}{\sqrt[3]{a \cdot -2}}
\end{array}
Initial program 43.3%
Applied egg-rr45.6%
Taylor expanded in g around inf
Simplified25.4%
Taylor expanded in g around inf
Simplified95.1%
Taylor expanded in a around 0
Simplified95.1%
Final simplification95.1%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (/ 1.0 (* a 2.0))))
(if (<= t_0 -4e+116)
(* (pow (- a) -0.3333333333333333) (cbrt g))
(if (<= t_0 5e+72)
(- (cbrt (* g (/ 1.0 a))))
(* (cbrt (- g)) (pow a -0.3333333333333333))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (a * 2.0);
double tmp;
if (t_0 <= -4e+116) {
tmp = pow(-a, -0.3333333333333333) * cbrt(g);
} else if (t_0 <= 5e+72) {
tmp = -cbrt((g * (1.0 / a)));
} else {
tmp = cbrt(-g) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (a * 2.0);
double tmp;
if (t_0 <= -4e+116) {
tmp = Math.pow(-a, -0.3333333333333333) * Math.cbrt(g);
} else if (t_0 <= 5e+72) {
tmp = -Math.cbrt((g * (1.0 / a)));
} else {
tmp = Math.cbrt(-g) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(a * 2.0)) tmp = 0.0 if (t_0 <= -4e+116) tmp = Float64((Float64(-a) ^ -0.3333333333333333) * cbrt(g)); elseif (t_0 <= 5e+72) tmp = Float64(-cbrt(Float64(g * Float64(1.0 / a)))); else tmp = Float64(cbrt(Float64(-g)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+116], N[(N[Power[(-a), -0.3333333333333333], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+72], (-N[Power[N[(g * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{a \cdot 2}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+116}:\\
\;\;\;\;{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{g}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+72}:\\
\;\;\;\;-\sqrt[3]{g \cdot \frac{1}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < -4.00000000000000006e116Initial program 42.8%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6422.9
Simplified22.9%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6448.1
Simplified48.1%
*-commutativeN/A
cbrt-unprodN/A
neg-mul-1N/A
distribute-frac-neg2N/A
clear-numN/A
associate-/r/N/A
cbrt-prodN/A
pow1/3N/A
*-lowering-*.f64N/A
inv-powN/A
pow-powN/A
pow-lowering-pow.f64N/A
neg-lowering-neg.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f6486.1
Applied egg-rr86.1%
if -4.00000000000000006e116 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 4.99999999999999992e72Initial program 46.0%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6431.0
Simplified31.0%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6492.8
Simplified92.8%
Taylor expanded in a around -inf
rem-cube-cbrtN/A
*-commutativeN/A
mul-1-negN/A
neg-lowering-neg.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6492.8
Simplified92.8%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f6492.9
Applied egg-rr92.9%
if 4.99999999999999992e72 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 31.4%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6410.5
Simplified10.5%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6438.9
Simplified38.9%
*-commutativeN/A
cbrt-unprodN/A
neg-mul-1N/A
div-invN/A
distribute-lft-neg-inN/A
cbrt-prodN/A
pow1/3N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
neg-lowering-neg.f64N/A
inv-powN/A
pow-powN/A
pow-lowering-pow.f64N/A
metadata-eval85.6
Applied egg-rr85.6%
Final simplification90.8%
(FPCore (g h a) :precision binary64 (if (<= (/ 1.0 (* a 2.0)) 5e+72) (- (cbrt (* g (/ 1.0 a)))) (* (cbrt (- g)) (pow a -0.3333333333333333))))
double code(double g, double h, double a) {
double tmp;
if ((1.0 / (a * 2.0)) <= 5e+72) {
tmp = -cbrt((g * (1.0 / a)));
} else {
tmp = cbrt(-g) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((1.0 / (a * 2.0)) <= 5e+72) {
tmp = -Math.cbrt((g * (1.0 / a)));
} else {
tmp = Math.cbrt(-g) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (Float64(1.0 / Float64(a * 2.0)) <= 5e+72) tmp = Float64(-cbrt(Float64(g * Float64(1.0 / a)))); else tmp = Float64(cbrt(Float64(-g)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, h_, a_] := If[LessEqual[N[(1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 5e+72], (-N[Power[N[(g * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{a \cdot 2} \leq 5 \cdot 10^{+72}:\\
\;\;\;\;-\sqrt[3]{g \cdot \frac{1}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 4.99999999999999992e72Initial program 45.5%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6429.6
Simplified29.6%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6485.0
Simplified85.0%
Taylor expanded in a around -inf
rem-cube-cbrtN/A
*-commutativeN/A
mul-1-negN/A
neg-lowering-neg.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6485.0
Simplified85.0%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f6485.0
Applied egg-rr85.0%
if 4.99999999999999992e72 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 31.4%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6410.5
Simplified10.5%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6438.9
Simplified38.9%
*-commutativeN/A
cbrt-unprodN/A
neg-mul-1N/A
div-invN/A
distribute-lft-neg-inN/A
cbrt-prodN/A
pow1/3N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
neg-lowering-neg.f64N/A
inv-powN/A
pow-powN/A
pow-lowering-pow.f64N/A
metadata-eval85.6
Applied egg-rr85.6%
Final simplification85.1%
(FPCore (g h a) :precision binary64 (/ (cbrt (- g)) (cbrt a)))
double code(double g, double h, double a) {
return cbrt(-g) / cbrt(a);
}
public static double code(double g, double h, double a) {
return Math.cbrt(-g) / Math.cbrt(a);
}
function code(g, h, a) return Float64(cbrt(Float64(-g)) / cbrt(a)) end
code[g_, h_, a_] := N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{-g}}{\sqrt[3]{a}}
\end{array}
Initial program 43.3%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6426.6
Simplified26.6%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6478.0
Simplified78.0%
*-commutativeN/A
cbrt-unprodN/A
neg-mul-1N/A
distribute-frac-negN/A
cbrt-divN/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f64N/A
neg-lowering-neg.f64N/A
cbrt-lowering-cbrt.f6495.0
Applied egg-rr95.0%
(FPCore (g h a) :precision binary64 (- (cbrt (* g (/ 1.0 a)))))
double code(double g, double h, double a) {
return -cbrt((g * (1.0 / a)));
}
public static double code(double g, double h, double a) {
return -Math.cbrt((g * (1.0 / a)));
}
function code(g, h, a) return Float64(-cbrt(Float64(g * Float64(1.0 / a)))) end
code[g_, h_, a_] := (-N[Power[N[(g * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision])
\begin{array}{l}
\\
-\sqrt[3]{g \cdot \frac{1}{a}}
\end{array}
Initial program 43.3%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6426.6
Simplified26.6%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6478.0
Simplified78.0%
Taylor expanded in a around -inf
rem-cube-cbrtN/A
*-commutativeN/A
mul-1-negN/A
neg-lowering-neg.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6478.0
Simplified78.0%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f6478.0
Applied egg-rr78.0%
Final simplification78.0%
(FPCore (g h a) :precision binary64 (if (<= (* a 2.0) -4e-306) (cbrt (+ g g)) (- (- g) g)))
double code(double g, double h, double a) {
double tmp;
if ((a * 2.0) <= -4e-306) {
tmp = cbrt((g + g));
} else {
tmp = -g - g;
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if ((a * 2.0) <= -4e-306) {
tmp = Math.cbrt((g + g));
} else {
tmp = -g - g;
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (Float64(a * 2.0) <= -4e-306) tmp = cbrt(Float64(g + g)); else tmp = Float64(Float64(-g) - g); end return tmp end
code[g_, h_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -4e-306], N[Power[N[(g + g), $MachinePrecision], 1/3], $MachinePrecision], N[((-g) - g), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -4 \cdot 10^{-306}:\\
\;\;\;\;\sqrt[3]{g + g}\\
\mathbf{else}:\\
\;\;\;\;\left(-g\right) - g\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.00000000000000011e-306Initial program 45.1%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6431.3
Simplified31.3%
Taylor expanded in g around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f649.6
Simplified9.6%
cbrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
*-rgt-identityN/A
pow1/3N/A
inv-powN/A
pow-powN/A
*-commutativeN/A
unpow-prod-downN/A
pow-powN/A
inv-powN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr0.0%
distribute-lft-neg-outN/A
neg-sub0N/A
associate-*r*N/A
pow-prod-downN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
Applied egg-rr7.8%
if -4.00000000000000011e-306 < (*.f64 #s(literal 2 binary64) a) Initial program 41.7%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6422.6
Simplified22.6%
Taylor expanded in g around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f648.0
Simplified8.0%
cbrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
*-rgt-identityN/A
pow1/3N/A
inv-powN/A
pow-powN/A
*-commutativeN/A
unpow-prod-downN/A
pow-powN/A
inv-powN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr28.4%
distribute-lft-neg-outN/A
neg-sub0N/A
associate-*r*N/A
pow-prod-downN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
Applied egg-rr5.8%
Final simplification6.7%
(FPCore (g h a) :precision binary64 (- (cbrt (/ g a))))
double code(double g, double h, double a) {
return -cbrt((g / a));
}
public static double code(double g, double h, double a) {
return -Math.cbrt((g / a));
}
function code(g, h, a) return Float64(-cbrt(Float64(g / a))) end
code[g_, h_, a_] := (-N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision])
\begin{array}{l}
\\
-\sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 43.3%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6426.6
Simplified26.6%
Taylor expanded in g around inf
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f6478.0
Simplified78.0%
Taylor expanded in a around -inf
rem-cube-cbrtN/A
*-commutativeN/A
mul-1-negN/A
neg-lowering-neg.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6478.0
Simplified78.0%
(FPCore (g h a) :precision binary64 (* (- g) (/ -1.0 (+ g g))))
double code(double g, double h, double a) {
return -g * (-1.0 / (g + g));
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = -g * ((-1.0d0) / (g + g))
end function
public static double code(double g, double h, double a) {
return -g * (-1.0 / (g + g));
}
def code(g, h, a): return -g * (-1.0 / (g + g))
function code(g, h, a) return Float64(Float64(-g) * Float64(-1.0 / Float64(g + g))) end
function tmp = code(g, h, a) tmp = -g * (-1.0 / (g + g)); end
code[g_, h_, a_] := N[((-g) * N[(-1.0 / N[(g + g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-g\right) \cdot \frac{-1}{g + g}
\end{array}
Initial program 43.3%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6426.6
Simplified26.6%
Taylor expanded in g around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f648.7
Simplified8.7%
cbrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
*-rgt-identityN/A
pow1/3N/A
inv-powN/A
pow-powN/A
*-commutativeN/A
unpow-prod-downN/A
pow-powN/A
inv-powN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr15.1%
Applied egg-rr4.8%
(FPCore (g h a) :precision binary64 (if (<= (* a 2.0) -5e-310) (+ g g) (- (- g) g)))
double code(double g, double h, double a) {
double tmp;
if ((a * 2.0) <= -5e-310) {
tmp = g + g;
} else {
tmp = -g - g;
}
return tmp;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
real(8) :: tmp
if ((a * 2.0d0) <= (-5d-310)) then
tmp = g + g
else
tmp = -g - g
end if
code = tmp
end function
public static double code(double g, double h, double a) {
double tmp;
if ((a * 2.0) <= -5e-310) {
tmp = g + g;
} else {
tmp = -g - g;
}
return tmp;
}
def code(g, h, a): tmp = 0 if (a * 2.0) <= -5e-310: tmp = g + g else: tmp = -g - g return tmp
function code(g, h, a) tmp = 0.0 if (Float64(a * 2.0) <= -5e-310) tmp = Float64(g + g); else tmp = Float64(Float64(-g) - g); end return tmp end
function tmp_2 = code(g, h, a) tmp = 0.0; if ((a * 2.0) <= -5e-310) tmp = g + g; else tmp = -g - g; end tmp_2 = tmp; end
code[g_, h_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -5e-310], N[(g + g), $MachinePrecision], N[((-g) - g), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;g + g\\
\mathbf{else}:\\
\;\;\;\;\left(-g\right) - g\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.999999999999985e-310Initial program 45.1%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6431.3
Simplified31.3%
Taylor expanded in g around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f649.6
Simplified9.6%
cbrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
*-rgt-identityN/A
pow1/3N/A
inv-powN/A
pow-powN/A
*-commutativeN/A
unpow-prod-downN/A
pow-powN/A
inv-powN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr0.0%
distribute-lft-neg-outN/A
neg-sub0N/A
associate-*r*N/A
pow-prod-downN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
Applied egg-rr6.2%
if -4.999999999999985e-310 < (*.f64 #s(literal 2 binary64) a) Initial program 41.7%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6422.6
Simplified22.6%
Taylor expanded in g around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f648.0
Simplified8.0%
cbrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
*-rgt-identityN/A
pow1/3N/A
inv-powN/A
pow-powN/A
*-commutativeN/A
unpow-prod-downN/A
pow-powN/A
inv-powN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr28.4%
distribute-lft-neg-outN/A
neg-sub0N/A
associate-*r*N/A
pow-prod-downN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
Applied egg-rr5.8%
Final simplification6.0%
(FPCore (g h a) :precision binary64 (+ g g))
double code(double g, double h, double a) {
return g + g;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = g + g
end function
public static double code(double g, double h, double a) {
return g + g;
}
def code(g, h, a): return g + g
function code(g, h, a) return Float64(g + g) end
function tmp = code(g, h, a) tmp = g + g; end
code[g_, h_, a_] := N[(g + g), $MachinePrecision]
\begin{array}{l}
\\
g + g
\end{array}
Initial program 43.3%
Taylor expanded in g around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6426.6
Simplified26.6%
Taylor expanded in g around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f648.7
Simplified8.7%
cbrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
*-rgt-identityN/A
pow1/3N/A
inv-powN/A
pow-powN/A
*-commutativeN/A
unpow-prod-downN/A
pow-powN/A
inv-powN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr15.1%
distribute-lft-neg-outN/A
neg-sub0N/A
associate-*r*N/A
pow-prod-downN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
Applied egg-rr3.5%
herbie shell --seed 2024198
(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))))))))