
(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 14 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 (fma (/ (cbrt (* 2.0 g)) (cbrt a)) (cbrt -0.5) (* (/ (cbrt (* (/ h g) h)) (cbrt a)) (* (cbrt 0.5) (cbrt -0.5)))))
double code(double g, double h, double a) {
return fma((cbrt((2.0 * g)) / cbrt(a)), cbrt(-0.5), ((cbrt(((h / g) * h)) / cbrt(a)) * (cbrt(0.5) * cbrt(-0.5))));
}
function code(g, h, a) return fma(Float64(cbrt(Float64(2.0 * g)) / cbrt(a)), cbrt(-0.5), Float64(Float64(cbrt(Float64(Float64(h / g) * h)) / cbrt(a)) * Float64(cbrt(0.5) * cbrt(-0.5)))) end
code[g_, h_, a_] := N[(N[(N[Power[N[(2.0 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision] + N[(N[(N[Power[N[(N[(h / g), $MachinePrecision] * h), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[0.5, 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\sqrt[3]{2 \cdot g}}{\sqrt[3]{a}}, \sqrt[3]{-0.5}, \frac{\sqrt[3]{\frac{h}{g} \cdot h}}{\sqrt[3]{a}} \cdot \left(\sqrt[3]{0.5} \cdot \sqrt[3]{-0.5}\right)\right)
\end{array}
Initial program 46.3%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites73.2%
Applied rewrites94.2%
Applied rewrites94.9%
Applied rewrites98.2%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h))))
(t_1 (pow (* 2.0 a) -1.0))
(t_2
(+
(cbrt (* t_1 (+ (- g) t_0)))
(cbrt (* (/ -1.0 (* 2.0 a)) (+ g t_0)))))
(t_3 (/ 2.0 (* (* g g) a))))
(if (<= t_2 (- INFINITY))
(* (* (- g) (cbrt t_3)) (cbrt 0.5))
(if (<= t_2 2e+61)
(+
(cbrt (* t_1 (* (/ (* h h) g) -0.5)))
(cbrt (fma (/ 0.25 g) (/ (* h h) a) (/ (- g) a))))
(if (<= t_2 INFINITY)
(* (- g) (cbrt (* t_3 0.5)))
(* (* (cbrt (/ g a)) (cbrt -0.5)) (cbrt 2.0)))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = pow((2.0 * a), -1.0);
double t_2 = cbrt((t_1 * (-g + t_0))) + cbrt(((-1.0 / (2.0 * a)) * (g + t_0)));
double t_3 = 2.0 / ((g * g) * a);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (-g * cbrt(t_3)) * cbrt(0.5);
} else if (t_2 <= 2e+61) {
tmp = cbrt((t_1 * (((h * h) / g) * -0.5))) + cbrt(fma((0.25 / g), ((h * h) / a), (-g / a)));
} else if (t_2 <= ((double) INFINITY)) {
tmp = -g * cbrt((t_3 * 0.5));
} else {
tmp = (cbrt((g / a)) * cbrt(-0.5)) * cbrt(2.0);
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = Float64(2.0 * a) ^ -1.0 t_2 = Float64(cbrt(Float64(t_1 * Float64(Float64(-g) + t_0))) + cbrt(Float64(Float64(-1.0 / Float64(2.0 * a)) * Float64(g + t_0)))) t_3 = Float64(2.0 / Float64(Float64(g * g) * a)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(-g) * cbrt(t_3)) * cbrt(0.5)); elseif (t_2 <= 2e+61) tmp = Float64(cbrt(Float64(t_1 * Float64(Float64(Float64(h * h) / g) * -0.5))) + cbrt(fma(Float64(0.25 / g), Float64(Float64(h * h) / a), Float64(Float64(-g) / a)))); elseif (t_2 <= Inf) tmp = Float64(Float64(-g) * cbrt(Float64(t_3 * 0.5))); else tmp = Float64(Float64(cbrt(Float64(g / a)) * cbrt(-0.5)) * cbrt(2.0)); 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[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(t$95$1 * N[((-g) + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(g + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[((-g) * N[Power[t$95$3, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+61], N[(N[Power[N[(t$95$1 * N[(N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.25 / g), $MachinePrecision] * N[(N[(h * h), $MachinePrecision] / a), $MachinePrecision] + N[((-g) / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[((-g) * N[Power[N[(t$95$3 * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := {\left(2 \cdot a\right)}^{-1}\\
t_2 := \sqrt[3]{t\_1 \cdot \left(\left(-g\right) + t\_0\right)} + \sqrt[3]{\frac{-1}{2 \cdot a} \cdot \left(g + t\_0\right)}\\
t_3 := \frac{2}{\left(g \cdot g\right) \cdot a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(\left(-g\right) \cdot \sqrt[3]{t\_3}\right) \cdot \sqrt[3]{0.5}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+61}:\\
\;\;\;\;\sqrt[3]{t\_1 \cdot \left(\frac{h \cdot h}{g} \cdot -0.5\right)} + \sqrt[3]{\mathsf{fma}\left(\frac{0.25}{g}, \frac{h \cdot h}{a}, \frac{-g}{a}\right)}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left(-g\right) \cdot \sqrt[3]{t\_3 \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-0.5}\right) \cdot \sqrt[3]{2}\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < -inf.0Initial program 4.3%
Applied rewrites0.8%
lift-pow.f64N/A
unpow-1N/A
lower-/.f640.8
Applied rewrites0.8%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites98.8%
Applied rewrites99.2%
if -inf.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 1.9999999999999999e61Initial program 88.5%
Taylor expanded in g around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6447.2
Applied rewrites47.2%
Taylor expanded in h around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6493.1
Applied rewrites93.1%
if 1.9999999999999999e61 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < +inf.0Initial program 56.8%
Applied rewrites11.1%
lift-pow.f64N/A
unpow-1N/A
lower-/.f6411.1
Applied rewrites11.1%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites97.5%
Applied rewrites97.8%
if +inf.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 0.0%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites57.7%
Taylor expanded in g around inf
Applied rewrites57.2%
Final simplification78.1%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (cbrt (/ (- g) a))))
(if (<=
(+
(cbrt (* (pow (* 2.0 a) -1.0) (+ (- g) t_0)))
(cbrt (* (/ -1.0 (* 2.0 a)) (+ g t_0))))
INFINITY)
(* (* (- g) (cbrt (/ 2.0 (* (* g g) a)))) (cbrt 0.5))
(+ t_1 t_1))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = cbrt((-g / a));
double tmp;
if ((cbrt((pow((2.0 * a), -1.0) * (-g + t_0))) + cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= ((double) INFINITY)) {
tmp = (-g * cbrt((2.0 / ((g * g) * a)))) * cbrt(0.5);
} else {
tmp = t_1 + t_1;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = Math.cbrt((-g / a));
double tmp;
if ((Math.cbrt((Math.pow((2.0 * a), -1.0) * (-g + t_0))) + Math.cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= Double.POSITIVE_INFINITY) {
tmp = (-g * Math.cbrt((2.0 / ((g * g) * a)))) * Math.cbrt(0.5);
} else {
tmp = t_1 + t_1;
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (Float64(cbrt(Float64((Float64(2.0 * a) ^ -1.0) * Float64(Float64(-g) + t_0))) + cbrt(Float64(Float64(-1.0 / Float64(2.0 * a)) * Float64(g + t_0)))) <= Inf) tmp = Float64(Float64(Float64(-g) * cbrt(Float64(2.0 / Float64(Float64(g * g) * a)))) * cbrt(0.5)); else tmp = Float64(t_1 + t_1); 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[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision] * N[((-g) + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(g + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], Infinity], N[(N[((-g) * N[Power[N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$1 + t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;\sqrt[3]{{\left(2 \cdot a\right)}^{-1} \cdot \left(\left(-g\right) + t\_0\right)} + \sqrt[3]{\frac{-1}{2 \cdot a} \cdot \left(g + t\_0\right)} \leq \infty:\\
\;\;\;\;\left(\left(-g\right) \cdot \sqrt[3]{\frac{2}{\left(g \cdot g\right) \cdot a}}\right) \cdot \sqrt[3]{0.5}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + t\_1\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < +inf.0Initial program 81.2%
Applied rewrites21.6%
lift-pow.f64N/A
unpow-1N/A
lower-/.f6421.6
Applied rewrites21.6%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites70.5%
Applied rewrites70.9%
if +inf.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 0.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f642.0
Applied rewrites2.0%
Taylor expanded in g around -inf
lower-*.f6412.7
Applied rewrites12.7%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6412.7
Applied rewrites12.7%
Final simplification45.9%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (cbrt (/ (- g) a))))
(if (<=
(+
(cbrt (* (pow (* 2.0 a) -1.0) (+ (- g) t_0)))
(cbrt (* (/ -1.0 (* 2.0 a)) (+ g t_0))))
INFINITY)
(* (* (- g) (cbrt 0.5)) (cbrt (/ 2.0 (* (* g g) a))))
(+ t_1 t_1))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = cbrt((-g / a));
double tmp;
if ((cbrt((pow((2.0 * a), -1.0) * (-g + t_0))) + cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= ((double) INFINITY)) {
tmp = (-g * cbrt(0.5)) * cbrt((2.0 / ((g * g) * a)));
} else {
tmp = t_1 + t_1;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = Math.cbrt((-g / a));
double tmp;
if ((Math.cbrt((Math.pow((2.0 * a), -1.0) * (-g + t_0))) + Math.cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= Double.POSITIVE_INFINITY) {
tmp = (-g * Math.cbrt(0.5)) * Math.cbrt((2.0 / ((g * g) * a)));
} else {
tmp = t_1 + t_1;
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (Float64(cbrt(Float64((Float64(2.0 * a) ^ -1.0) * Float64(Float64(-g) + t_0))) + cbrt(Float64(Float64(-1.0 / Float64(2.0 * a)) * Float64(g + t_0)))) <= Inf) tmp = Float64(Float64(Float64(-g) * cbrt(0.5)) * cbrt(Float64(2.0 / Float64(Float64(g * g) * a)))); else tmp = Float64(t_1 + t_1); 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[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision] * N[((-g) + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(g + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], Infinity], N[(N[((-g) * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$1 + t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;\sqrt[3]{{\left(2 \cdot a\right)}^{-1} \cdot \left(\left(-g\right) + t\_0\right)} + \sqrt[3]{\frac{-1}{2 \cdot a} \cdot \left(g + t\_0\right)} \leq \infty:\\
\;\;\;\;\left(\left(-g\right) \cdot \sqrt[3]{0.5}\right) \cdot \sqrt[3]{\frac{2}{\left(g \cdot g\right) \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + t\_1\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < +inf.0Initial program 81.2%
Applied rewrites21.6%
lift-pow.f64N/A
unpow-1N/A
lower-/.f6421.6
Applied rewrites21.6%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites70.5%
Applied rewrites70.8%
if +inf.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 0.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f642.0
Applied rewrites2.0%
Taylor expanded in g around -inf
lower-*.f6412.7
Applied rewrites12.7%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6412.7
Applied rewrites12.7%
Final simplification45.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (cbrt (/ (- g) a))))
(if (<=
(+
(cbrt (* (pow (* 2.0 a) -1.0) (+ (- g) t_0)))
(cbrt (* (/ -1.0 (* 2.0 a)) (+ g t_0))))
INFINITY)
(* (- g) (cbrt (* (/ 2.0 (* (* g g) a)) 0.5)))
(+ t_1 t_1))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = cbrt((-g / a));
double tmp;
if ((cbrt((pow((2.0 * a), -1.0) * (-g + t_0))) + cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= ((double) INFINITY)) {
tmp = -g * cbrt(((2.0 / ((g * g) * a)) * 0.5));
} else {
tmp = t_1 + t_1;
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = Math.cbrt((-g / a));
double tmp;
if ((Math.cbrt((Math.pow((2.0 * a), -1.0) * (-g + t_0))) + Math.cbrt(((-1.0 / (2.0 * a)) * (g + t_0)))) <= Double.POSITIVE_INFINITY) {
tmp = -g * Math.cbrt(((2.0 / ((g * g) * a)) * 0.5));
} else {
tmp = t_1 + t_1;
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = cbrt(Float64(Float64(-g) / a)) tmp = 0.0 if (Float64(cbrt(Float64((Float64(2.0 * a) ^ -1.0) * Float64(Float64(-g) + t_0))) + cbrt(Float64(Float64(-1.0 / Float64(2.0 * a)) * Float64(g + t_0)))) <= Inf) tmp = Float64(Float64(-g) * cbrt(Float64(Float64(2.0 / Float64(Float64(g * g) * a)) * 0.5))); else tmp = Float64(t_1 + t_1); 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[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision] * N[((-g) + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(g + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], Infinity], N[((-g) * N[Power[N[(N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$1 + t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := \sqrt[3]{\frac{-g}{a}}\\
\mathbf{if}\;\sqrt[3]{{\left(2 \cdot a\right)}^{-1} \cdot \left(\left(-g\right) + t\_0\right)} + \sqrt[3]{\frac{-1}{2 \cdot a} \cdot \left(g + t\_0\right)} \leq \infty:\\
\;\;\;\;\left(-g\right) \cdot \sqrt[3]{\frac{2}{\left(g \cdot g\right) \cdot a} \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + t\_1\\
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < +inf.0Initial program 81.2%
Applied rewrites21.6%
lift-pow.f64N/A
unpow-1N/A
lower-/.f6421.6
Applied rewrites21.6%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites70.5%
Applied rewrites70.8%
if +inf.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 0.0%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f642.0
Applied rewrites2.0%
Taylor expanded in g around -inf
lower-*.f6412.7
Applied rewrites12.7%
Taylor expanded in g around -inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6412.7
Applied rewrites12.7%
Final simplification45.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (pow (* 2.0 a) -1.0)))
(if (or (<= t_0 -5e+171) (not (<= t_0 5e+119)))
(* (- g) (* (cbrt 0.5) (+ (cbrt 0.0) (cbrt (/ 2.0 (* (* a g) g))))))
(fma (cbrt (/ g a)) (cbrt -1.0) (cbrt (* -0.25 (* (/ h a) (/ h g))))))))
double code(double g, double h, double a) {
double t_0 = pow((2.0 * a), -1.0);
double tmp;
if ((t_0 <= -5e+171) || !(t_0 <= 5e+119)) {
tmp = -g * (cbrt(0.5) * (cbrt(0.0) + cbrt((2.0 / ((a * g) * g)))));
} else {
tmp = fma(cbrt((g / a)), cbrt(-1.0), cbrt((-0.25 * ((h / a) * (h / g)))));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(2.0 * a) ^ -1.0 tmp = 0.0 if ((t_0 <= -5e+171) || !(t_0 <= 5e+119)) tmp = Float64(Float64(-g) * Float64(cbrt(0.5) * Float64(cbrt(0.0) + cbrt(Float64(2.0 / Float64(Float64(a * g) * g)))))); else tmp = fma(cbrt(Float64(g / a)), cbrt(-1.0), cbrt(Float64(-0.25 * Float64(Float64(h / a) * Float64(h / g))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+171], N[Not[LessEqual[t$95$0, 5e+119]], $MachinePrecision]], N[((-g) * N[(N[Power[0.5, 1/3], $MachinePrecision] * N[(N[Power[0.0, 1/3], $MachinePrecision] + N[Power[N[(2.0 / N[(N[(a * g), $MachinePrecision] * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(-0.25 * N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(2 \cdot a\right)}^{-1}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+171} \lor \neg \left(t\_0 \leq 5 \cdot 10^{+119}\right):\\
\;\;\;\;\left(-g\right) \cdot \left(\sqrt[3]{0.5} \cdot \left(\sqrt[3]{0} + \sqrt[3]{\frac{2}{\left(a \cdot g\right) \cdot g}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{g}{a}}, \sqrt[3]{-1}, \sqrt[3]{-0.25 \cdot \left(\frac{h}{a} \cdot \frac{h}{g}\right)}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < -5.0000000000000004e171 or 4.9999999999999999e119 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 24.0%
Applied rewrites4.9%
lift-pow.f64N/A
unpow-1N/A
lower-/.f644.9
Applied rewrites4.9%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites39.8%
Applied rewrites77.8%
if -5.0000000000000004e171 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 4.9999999999999999e119Initial program 54.0%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites88.7%
Applied rewrites89.8%
Final simplification86.7%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (pow (* 2.0 a) -1.0)))
(if (or (<= t_0 -5e+242) (not (<= t_0 2e+256)))
(* (- g) (cbrt (* (/ 2.0 (* (* g g) a)) 0.5)))
(fma (cbrt (/ g a)) (cbrt -1.0) (cbrt (* -0.25 (* (/ h a) (/ h g))))))))
double code(double g, double h, double a) {
double t_0 = pow((2.0 * a), -1.0);
double tmp;
if ((t_0 <= -5e+242) || !(t_0 <= 2e+256)) {
tmp = -g * cbrt(((2.0 / ((g * g) * a)) * 0.5));
} else {
tmp = fma(cbrt((g / a)), cbrt(-1.0), cbrt((-0.25 * ((h / a) * (h / g)))));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(2.0 * a) ^ -1.0 tmp = 0.0 if ((t_0 <= -5e+242) || !(t_0 <= 2e+256)) tmp = Float64(Float64(-g) * cbrt(Float64(Float64(2.0 / Float64(Float64(g * g) * a)) * 0.5))); else tmp = fma(cbrt(Float64(g / a)), cbrt(-1.0), cbrt(Float64(-0.25 * Float64(Float64(h / a) * Float64(h / g))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+242], N[Not[LessEqual[t$95$0, 2e+256]], $MachinePrecision]], N[((-g) * N[Power[N[(N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(-0.25 * N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(2 \cdot a\right)}^{-1}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+242} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+256}\right):\\
\;\;\;\;\left(-g\right) \cdot \sqrt[3]{\frac{2}{\left(g \cdot g\right) \cdot a} \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{g}{a}}, \sqrt[3]{-1}, \sqrt[3]{-0.25 \cdot \left(\frac{h}{a} \cdot \frac{h}{g}\right)}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < -5.0000000000000004e242 or 2.0000000000000001e256 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 16.7%
Applied rewrites8.4%
lift-pow.f64N/A
unpow-1N/A
lower-/.f648.4
Applied rewrites8.4%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites54.9%
Applied rewrites55.1%
if -5.0000000000000004e242 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 2.0000000000000001e256Initial program 49.8%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites79.7%
Applied rewrites80.6%
Final simplification77.9%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (pow (* 2.0 a) -1.0)))
(if (or (<= t_0 -5e+242) (not (<= t_0 2e+256)))
(* (- g) (cbrt (* (/ 2.0 (* (* g g) a)) 0.5)))
(+ (cbrt (* (/ -0.25 a) (/ (* h h) g))) (cbrt (/ (- g) a))))))
double code(double g, double h, double a) {
double t_0 = pow((2.0 * a), -1.0);
double tmp;
if ((t_0 <= -5e+242) || !(t_0 <= 2e+256)) {
tmp = -g * cbrt(((2.0 / ((g * g) * a)) * 0.5));
} else {
tmp = cbrt(((-0.25 / a) * ((h * h) / g))) + cbrt((-g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.pow((2.0 * a), -1.0);
double tmp;
if ((t_0 <= -5e+242) || !(t_0 <= 2e+256)) {
tmp = -g * Math.cbrt(((2.0 / ((g * g) * a)) * 0.5));
} else {
tmp = Math.cbrt(((-0.25 / a) * ((h * h) / g))) + Math.cbrt((-g / a));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(2.0 * a) ^ -1.0 tmp = 0.0 if ((t_0 <= -5e+242) || !(t_0 <= 2e+256)) tmp = Float64(Float64(-g) * cbrt(Float64(Float64(2.0 / Float64(Float64(g * g) * a)) * 0.5))); else tmp = Float64(cbrt(Float64(Float64(-0.25 / a) * Float64(Float64(h * h) / g))) + cbrt(Float64(Float64(-g) / a))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(2.0 * a), $MachinePrecision], -1.0], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+242], N[Not[LessEqual[t$95$0, 2e+256]], $MachinePrecision]], N[((-g) * N[Power[N[(N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(-0.25 / a), $MachinePrecision] * N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[((-g) / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(2 \cdot a\right)}^{-1}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+242} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+256}\right):\\
\;\;\;\;\left(-g\right) \cdot \sqrt[3]{\frac{2}{\left(g \cdot g\right) \cdot a} \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.25}{a} \cdot \frac{h \cdot h}{g}} + \sqrt[3]{\frac{-g}{a}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < -5.0000000000000004e242 or 2.0000000000000001e256 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) Initial program 16.7%
Applied rewrites8.4%
lift-pow.f64N/A
unpow-1N/A
lower-/.f648.4
Applied rewrites8.4%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites54.9%
Applied rewrites55.1%
if -5.0000000000000004e242 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 2.0000000000000001e256Initial program 49.8%
Taylor expanded in g around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.4
Applied rewrites29.4%
Taylor expanded in g around -inf
lower-*.f6416.0
Applied rewrites16.0%
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-*.f6476.4
Applied rewrites76.4%
Final simplification74.1%
(FPCore (g h a) :precision binary64 (fma (cbrt (* g 2.0)) (/ (cbrt -0.5) (cbrt a)) (cbrt (* (* -0.25 (/ h a)) (/ h g)))))
double code(double g, double h, double a) {
return fma(cbrt((g * 2.0)), (cbrt(-0.5) / cbrt(a)), cbrt(((-0.25 * (h / a)) * (h / g))));
}
function code(g, h, a) return fma(cbrt(Float64(g * 2.0)), Float64(cbrt(-0.5) / cbrt(a)), cbrt(Float64(Float64(-0.25 * Float64(h / a)) * Float64(h / g)))) end
code[g_, h_, a_] := N[(N[Power[N[(g * 2.0), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(-0.25 * N[(h / a), $MachinePrecision]), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sqrt[3]{g \cdot 2}, \frac{\sqrt[3]{-0.5}}{\sqrt[3]{a}}, \sqrt[3]{\left(-0.25 \cdot \frac{h}{a}\right) \cdot \frac{h}{g}}\right)
\end{array}
Initial program 46.3%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites73.2%
Applied rewrites94.2%
Applied rewrites94.9%
Applied rewrites94.9%
(FPCore (g h a) :precision binary64 (* (- g) (cbrt (* (/ 2.0 (* (* g g) a)) 0.5))))
double code(double g, double h, double a) {
return -g * cbrt(((2.0 / ((g * g) * a)) * 0.5));
}
public static double code(double g, double h, double a) {
return -g * Math.cbrt(((2.0 / ((g * g) * a)) * 0.5));
}
function code(g, h, a) return Float64(Float64(-g) * cbrt(Float64(Float64(2.0 / Float64(Float64(g * g) * a)) * 0.5))) end
code[g_, h_, a_] := N[((-g) * N[Power[N[(N[(2.0 / N[(N[(g * g), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-g\right) \cdot \sqrt[3]{\frac{2}{\left(g \cdot g\right) \cdot a} \cdot 0.5}
\end{array}
Initial program 46.3%
Applied rewrites13.0%
lift-pow.f64N/A
unpow-1N/A
lower-/.f6413.0
Applied rewrites13.0%
Taylor expanded in g around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-+.f64N/A
Applied rewrites41.3%
Applied rewrites41.5%
(FPCore (g h a) :precision binary64 (cbrt (* (/ h a) (* -0.25 (/ h g)))))
double code(double g, double h, double a) {
return cbrt(((h / a) * (-0.25 * (h / g))));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((h / a) * (-0.25 * (h / g))));
}
function code(g, h, a) return cbrt(Float64(Float64(h / a) * Float64(-0.25 * Float64(h / g)))) end
code[g_, h_, a_] := N[Power[N[(N[(h / a), $MachinePrecision] * N[(-0.25 * N[(h / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{h}{a} \cdot \left(-0.25 \cdot \frac{h}{g}\right)}
\end{array}
Initial program 46.3%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites73.2%
Taylor expanded in g around 0
Applied rewrites4.1%
Applied rewrites4.7%
Applied rewrites4.7%
(FPCore (g h a) :precision binary64 (cbrt (* (* (/ h a) (/ h g)) -0.25)))
double code(double g, double h, double a) {
return cbrt((((h / a) * (h / g)) * -0.25));
}
public static double code(double g, double h, double a) {
return Math.cbrt((((h / a) * (h / g)) * -0.25));
}
function code(g, h, a) return cbrt(Float64(Float64(Float64(h / a) * Float64(h / g)) * -0.25)) end
code[g_, h_, a_] := N[Power[N[(N[(N[(h / a), $MachinePrecision] * N[(h / g), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(\frac{h}{a} \cdot \frac{h}{g}\right) \cdot -0.25}
\end{array}
Initial program 46.3%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites73.2%
Taylor expanded in g around 0
Applied rewrites4.1%
Applied rewrites4.7%
(FPCore (g h a) :precision binary64 (cbrt (* (/ -0.25 g) (/ (* h h) a))))
double code(double g, double h, double a) {
return cbrt(((-0.25 / g) * ((h * h) / a)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-0.25 / g) * ((h * h) / a)));
}
function code(g, h, a) return cbrt(Float64(Float64(-0.25 / g) * Float64(Float64(h * h) / a))) end
code[g_, h_, a_] := N[Power[N[(N[(-0.25 / g), $MachinePrecision] * N[(N[(h * h), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-0.25}{g} \cdot \frac{h \cdot h}{a}}
\end{array}
Initial program 46.3%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites73.2%
Taylor expanded in g around 0
Applied rewrites4.1%
Applied rewrites4.7%
Taylor expanded in g around 0
Applied rewrites4.1%
(FPCore (g h a) :precision binary64 (cbrt (/ (* (* h h) -0.25) (* a g))))
double code(double g, double h, double a) {
return cbrt((((h * h) * -0.25) / (a * g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt((((h * h) * -0.25) / (a * g)));
}
function code(g, h, a) return cbrt(Float64(Float64(Float64(h * h) * -0.25) / Float64(a * g))) end
code[g_, h_, a_] := N[Power[N[(N[(N[(h * h), $MachinePrecision] * -0.25), $MachinePrecision] / N[(a * g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{\left(h \cdot h\right) \cdot -0.25}{a \cdot g}}
\end{array}
Initial program 46.3%
Taylor expanded in h around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
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
Applied rewrites73.2%
Taylor expanded in g around 0
Applied rewrites4.1%
Applied rewrites4.7%
Applied rewrites4.1%
herbie shell --seed 2024360
(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))))))))