
(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 9 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
(if (<= g 6.8e+77)
(+
(cbrt (* (/ 0.5 a) (* -0.5 (* h (/ h g)))))
(* (* (cbrt g) (cbrt (/ 1.0 a))) (* (cbrt -0.5) (cbrt 2.0))))
(+ (* (cbrt (/ 0.5 a)) (cbrt (* g -2.0))) (cbrt (* (- g g) (/ -0.5 a))))))
double code(double g, double h, double a) {
double tmp;
if (g <= 6.8e+77) {
tmp = cbrt(((0.5 / a) * (-0.5 * (h * (h / g))))) + ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * cbrt(2.0)));
} else {
tmp = (cbrt((0.5 / a)) * cbrt((g * -2.0))) + cbrt(((g - g) * (-0.5 / a)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= 6.8e+77) {
tmp = Math.cbrt(((0.5 / a) * (-0.5 * (h * (h / g))))) + ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.cbrt(2.0)));
} else {
tmp = (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + Math.cbrt(((g - g) * (-0.5 / a)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= 6.8e+77) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * Float64(h * Float64(h / g))))) + Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * cbrt(2.0)))); else tmp = Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, 6.8e+77], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * N[(h * N[(h / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq 6.8 \cdot 10^{+77}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \left(h \cdot \frac{h}{g}\right)\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\
\end{array}
\end{array}
if g < 6.79999999999999993e77Initial program 66.8%
Simplified66.8%
Taylor expanded in g around inf 62.0%
Taylor expanded in g around inf 73.6%
pow273.6%
associate-/l*81.3%
Applied egg-rr81.3%
pow1/342.2%
div-inv42.2%
unpow-prod-down40.8%
pow1/348.4%
Applied egg-rr48.4%
unpow1/392.8%
Simplified92.8%
if 6.79999999999999993e77 < g Initial program 19.7%
Simplified19.7%
Taylor expanded in g around -inf 6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in g around -inf 60.0%
neg-mul-160.0%
Simplified60.0%
cbrt-prod96.4%
Applied egg-rr96.4%
Final simplification94.9%
(FPCore (g h a)
:precision binary64
(if (<= g 2.5e+77)
(+
(cbrt (* (/ 0.5 a) (* -0.5 (* h (/ h g)))))
(* (* (cbrt -0.5) (cbrt 2.0)) (/ (cbrt g) (cbrt a))))
(+ (* (cbrt (/ 0.5 a)) (cbrt (* g -2.0))) (cbrt (* (- g g) (/ -0.5 a))))))
double code(double g, double h, double a) {
double tmp;
if (g <= 2.5e+77) {
tmp = cbrt(((0.5 / a) * (-0.5 * (h * (h / g))))) + ((cbrt(-0.5) * cbrt(2.0)) * (cbrt(g) / cbrt(a)));
} else {
tmp = (cbrt((0.5 / a)) * cbrt((g * -2.0))) + cbrt(((g - g) * (-0.5 / a)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= 2.5e+77) {
tmp = Math.cbrt(((0.5 / a) * (-0.5 * (h * (h / g))))) + ((Math.cbrt(-0.5) * Math.cbrt(2.0)) * (Math.cbrt(g) / Math.cbrt(a)));
} else {
tmp = (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + Math.cbrt(((g - g) * (-0.5 / a)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= 2.5e+77) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * Float64(h * Float64(h / g))))) + Float64(Float64(cbrt(-0.5) * cbrt(2.0)) * Float64(cbrt(g) / cbrt(a)))); else tmp = Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, 2.5e+77], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * N[(h * N[(h / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq 2.5 \cdot 10^{+77}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \left(h \cdot \frac{h}{g}\right)\right)} + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\
\end{array}
\end{array}
if g < 2.50000000000000002e77Initial program 66.8%
Simplified66.8%
Taylor expanded in g around inf 62.0%
Taylor expanded in g around inf 73.6%
pow273.6%
associate-/l*81.3%
Applied egg-rr81.3%
cbrt-div92.5%
div-inv92.5%
Applied egg-rr92.5%
associate-*r/92.5%
*-rgt-identity92.5%
Simplified92.5%
if 2.50000000000000002e77 < g Initial program 19.7%
Simplified19.7%
Taylor expanded in g around -inf 6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in g around -inf 60.0%
neg-mul-160.0%
Simplified60.0%
cbrt-prod96.4%
Applied egg-rr96.4%
Final simplification94.8%
(FPCore (g h a)
:precision binary64
(if (<= a -3.8e-122)
(- (cbrt (/ g a)))
(if (<= a 5.1e-76)
(+ (/ (cbrt (- g)) (cbrt a)) (cbrt -1.0))
(+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (* (/ 0.5 a) (* g -2.0)))))))
double code(double g, double h, double a) {
double tmp;
if (a <= -3.8e-122) {
tmp = -cbrt((g / a));
} else if (a <= 5.1e-76) {
tmp = (cbrt(-g) / cbrt(a)) + cbrt(-1.0);
} else {
tmp = cbrt(((g - g) * (-0.5 / a))) + cbrt(((0.5 / a) * (g * -2.0)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (a <= -3.8e-122) {
tmp = -Math.cbrt((g / a));
} else if (a <= 5.1e-76) {
tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-1.0);
} else {
tmp = Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(((0.5 / a) * (g * -2.0)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (a <= -3.8e-122) tmp = Float64(-cbrt(Float64(g / a))); elseif (a <= 5.1e-76) tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-1.0)); else tmp = Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[a, -3.8e-122], (-N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), If[LessEqual[a, 5.1e-76], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.8 \cdot 10^{-122}:\\
\;\;\;\;-\sqrt[3]{\frac{g}{a}}\\
\mathbf{elif}\;a \leq 5.1 \cdot 10^{-76}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\
\end{array}
\end{array}
if a < -3.8000000000000001e-122Initial program 47.8%
Simplified47.8%
Taylor expanded in g around -inf 12.8%
*-commutative12.8%
Simplified12.8%
Taylor expanded in g around inf 17.9%
Applied egg-rr0.0%
Simplified41.9%
Taylor expanded in g around -inf 89.2%
mul-1-neg89.2%
Simplified89.2%
if -3.8000000000000001e-122 < a < 5.09999999999999986e-76Initial program 33.6%
Simplified33.6%
Taylor expanded in g around -inf 11.6%
*-commutative11.6%
Simplified11.6%
Taylor expanded in g around inf 10.7%
Applied egg-rr0.0%
Simplified36.0%
add-sqr-sqrt12.9%
sqrt-unprod4.9%
*-commutative4.9%
*-commutative4.9%
swap-sqr3.8%
frac-times3.8%
metadata-eval3.8%
metadata-eval3.8%
frac-times3.8%
count-23.8%
count-23.8%
swap-sqr3.8%
metadata-eval3.8%
metadata-eval3.8%
swap-sqr3.8%
*-commutative3.8%
*-commutative3.8%
swap-sqr4.9%
sqrt-unprod12.9%
add-sqr-sqrt36.0%
Applied egg-rr88.8%
if 5.09999999999999986e-76 < a Initial program 37.0%
Simplified37.0%
Taylor expanded in g around -inf 9.5%
*-commutative9.5%
Simplified9.5%
Taylor expanded in g around -inf 76.1%
neg-mul-176.1%
Simplified76.1%
Final simplification85.4%
(FPCore (g h a) :precision binary64 (+ (* (cbrt (/ 0.5 a)) (cbrt (* g -2.0))) (cbrt (* (- g g) (/ -0.5 a)))))
double code(double g, double h, double a) {
return (cbrt((0.5 / a)) * cbrt((g * -2.0))) + cbrt(((g - g) * (-0.5 / a)));
}
public static double code(double g, double h, double a) {
return (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + Math.cbrt(((g - g) * (-0.5 / a)));
}
function code(g, h, a) return Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))) end
code[g_, h_, a_] := N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}
\end{array}
Initial program 39.0%
Simplified39.0%
Taylor expanded in g around -inf 11.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in g around -inf 65.7%
neg-mul-165.7%
Simplified65.7%
cbrt-prod92.2%
Applied egg-rr92.2%
Final simplification92.2%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (/ (cbrt (- g)) (cbrt a))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + (cbrt(-g) / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + (Math.cbrt(-g) / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + Float64(cbrt(Float64(-g)) / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}}
\end{array}
Initial program 39.0%
Simplified39.0%
Taylor expanded in g around -inf 11.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in g around -inf 65.7%
neg-mul-165.7%
Simplified65.7%
associate-*l/65.6%
cbrt-div92.2%
*-commutative92.2%
associate-*r*92.2%
metadata-eval92.2%
neg-mul-192.2%
Applied egg-rr92.2%
Final simplification92.2%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (* (/ 0.5 a) (* g -2.0)))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + cbrt(((0.5 / a) * (g * -2.0)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(((0.5 / a) * (g * -2.0)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}
\end{array}
Initial program 39.0%
Simplified39.0%
Taylor expanded in g around -inf 11.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in g around -inf 65.7%
neg-mul-165.7%
Simplified65.7%
Final simplification65.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 39.0%
Simplified39.0%
Taylor expanded in g around -inf 11.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in g around inf 14.5%
Applied egg-rr0.0%
Simplified38.0%
Taylor expanded in g around -inf 65.6%
mul-1-neg65.6%
Simplified65.6%
Final simplification65.6%
(FPCore (g h a) :precision binary64 (if (<= a -5e-310) 1.0 -1.0))
double code(double g, double h, double a) {
double tmp;
if (a <= -5e-310) {
tmp = 1.0;
} else {
tmp = -1.0;
}
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 <= (-5d-310)) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double g, double h, double a) {
double tmp;
if (a <= -5e-310) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(g, h, a): tmp = 0 if a <= -5e-310: tmp = 1.0 else: tmp = -1.0 return tmp
function code(g, h, a) tmp = 0.0 if (a <= -5e-310) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(g, h, a) tmp = 0.0; if (a <= -5e-310) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[g_, h_, a_] := If[LessEqual[a, -5e-310], 1.0, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 41.8%
Simplified41.8%
Taylor expanded in g around -inf 11.9%
*-commutative11.9%
Simplified11.9%
Taylor expanded in g around inf 15.0%
Applied egg-rr0.0%
Simplified38.1%
Applied egg-rr7.0%
if -4.999999999999985e-310 < a Initial program 36.4%
Simplified36.4%
Taylor expanded in g around -inf 10.9%
*-commutative10.9%
Simplified10.9%
Taylor expanded in g around inf 14.1%
Applied egg-rr0.0%
Simplified37.9%
Applied egg-rr6.8%
Final simplification6.9%
(FPCore (g h a) :precision binary64 -1.0)
double code(double g, double h, double a) {
return -1.0;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = -1.0d0
end function
public static double code(double g, double h, double a) {
return -1.0;
}
def code(g, h, a): return -1.0
function code(g, h, a) return -1.0 end
function tmp = code(g, h, a) tmp = -1.0; end
code[g_, h_, a_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 39.0%
Simplified39.0%
Taylor expanded in g around -inf 11.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in g around inf 14.5%
Applied egg-rr0.0%
Simplified38.0%
Applied egg-rr4.5%
Final simplification4.5%
herbie shell --seed 2024069
(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))))))))