
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) {
return cbrt((x + 1.0)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((x + 1.0)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x + 1} - \sqrt[3]{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) {
return cbrt((x + 1.0)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((x + 1.0)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x + 1} - \sqrt[3]{x}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0)))
(/ (- (+ 1.0 x) x) (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) t_1))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) + t_0;
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
} else {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * t_1));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), t_1, (cbrt(x) ^ 2.0))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * t_1))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} + t_0\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t_1}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+53.3%
+-inverses53.3%
metadata-eval53.3%
+-commutative53.3%
fma-def53.3%
+-commutative53.3%
+-commutative53.3%
Simplified53.3%
add-cube-cbrt53.1%
pow353.1%
pow1/350.9%
unpow250.9%
pow-prod-down42.0%
+-commutative42.0%
pow1/342.7%
+-commutative42.7%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 50.9%
metadata-eval50.9%
pow-base-150.9%
*-lft-identity50.9%
unpow1/353.3%
unpow253.3%
rem-cube-cbrt53.3%
rem-cube-cbrt53.1%
cube-prod53.2%
unpow253.2%
rem-cbrt-cube98.5%
Simplified98.5%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
flip3--98.2%
rem-cube-cbrt98.2%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x))))
(if (<= t_1 2e-7)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (cbrt (* x x))))
(exp (log t_1)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 2e-7) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), cbrt((x * x)));
} else {
tmp = exp(log(t_1));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 2e-7) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), cbrt(Float64(x * x)))); else tmp = exp(log(t_1)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-7], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[t$95$1], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \sqrt[3]{x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_1}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.9999999999999999e-7Initial program 4.9%
flip3--4.9%
div-inv4.9%
rem-cube-cbrt4.5%
rem-cube-cbrt5.7%
cbrt-unprod5.7%
pow25.7%
distribute-rgt-out5.7%
+-commutative5.7%
Applied egg-rr5.7%
associate-*r/5.7%
*-rgt-identity5.7%
+-commutative5.7%
associate--l+54.0%
+-inverses54.0%
metadata-eval54.0%
+-commutative54.0%
fma-def54.0%
+-commutative54.0%
+-commutative54.0%
Simplified54.0%
pow1/351.7%
pow-pow42.9%
metadata-eval42.9%
Applied egg-rr42.9%
Taylor expanded in x around inf 51.3%
unpow1/353.6%
unpow253.6%
Simplified53.6%
if 1.9999999999999999e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.1%
add-exp-log99.1%
Applied egg-rr99.1%
Final simplification76.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x))))
(if (<= t_1 0.0)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))
(exp (log t_1)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
} else {
tmp = exp(log(t_1));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); else tmp = exp(log(t_1)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[t$95$1], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_1}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+53.3%
+-inverses53.3%
metadata-eval53.3%
+-commutative53.3%
fma-def53.3%
+-commutative53.3%
+-commutative53.3%
Simplified53.3%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
add-exp-log98.3%
Applied egg-rr98.3%
Final simplification60.3%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {t_0}^{2}\right)}
\end{array}
\end{array}
Initial program 52.7%
flip3--52.7%
div-inv52.7%
rem-cube-cbrt52.5%
rem-cube-cbrt53.5%
cbrt-unprod53.5%
pow253.5%
distribute-rgt-out53.5%
+-commutative53.5%
Applied egg-rr53.5%
associate-*r/53.5%
*-rgt-identity53.5%
+-commutative53.5%
associate--l+77.3%
+-inverses77.3%
metadata-eval77.3%
+-commutative77.3%
fma-def77.3%
+-commutative77.3%
+-commutative77.3%
Simplified77.3%
expm1-log1p-u76.4%
expm1-udef76.4%
pow1/376.3%
unpow276.3%
pow-prod-down70.8%
+-commutative70.8%
pow1/370.9%
+-commutative70.9%
pow1/396.9%
pow296.9%
+-commutative96.9%
Applied egg-rr96.9%
expm1-def96.9%
expm1-log1p99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (cbrt (/ 1.0 (* x x))) (exp (log t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = exp(log(t_0));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x)) - Math.cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = Math.exp(Math.log(t_0));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) tmp = 0.0 if (t_0 <= 0.0) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = exp(log(t_0)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[Exp[N[Log[t$95$0], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+53.3%
+-inverses53.3%
metadata-eval53.3%
+-commutative53.3%
fma-def53.3%
+-commutative53.3%
+-commutative53.3%
Simplified53.3%
pow1/350.9%
pow-pow42.0%
metadata-eval42.0%
Applied egg-rr42.0%
Taylor expanded in x around inf 11.5%
unpow1/311.5%
unpow211.5%
Simplified11.5%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
add-exp-log98.3%
Applied egg-rr98.3%
Final simplification56.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= x -1.32e+154)
(/ 1.0 (fma (cbrt x) t_1 1.0))
(if (<= x 1.35e+154)
(/ 1.0 (+ (pow (cbrt x) 2.0) (+ (pow t_0 2.0) (cbrt (+ x (* x x))))))
(/ 1.0 (fma (cbrt x) t_1 (pow (+ 1.0 x) 0.6666666666666666)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) + t_0;
double tmp;
if (x <= -1.32e+154) {
tmp = 1.0 / fma(cbrt(x), t_1, 1.0);
} else if (x <= 1.35e+154) {
tmp = 1.0 / (pow(cbrt(x), 2.0) + (pow(t_0, 2.0) + cbrt((x + (x * x)))));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (x <= -1.32e+154) tmp = Float64(1.0 / fma(cbrt(x), t_1, 1.0)); elseif (x <= 1.35e+154) tmp = Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64((t_0 ^ 2.0) + cbrt(Float64(x + Float64(x * x)))))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[x, -1.32e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[Power[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} + t_0\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, 1\right)}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \left({t_0}^{2} + \sqrt[3]{x + x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1.31999999999999998e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.7%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
Taylor expanded in x around 0 20.0%
if -1.31999999999999998e154 < x < 1.35000000000000003e154Initial program 67.4%
add-sqr-sqrt33.2%
pow233.2%
pow1/333.6%
sqrt-pow133.6%
metadata-eval33.6%
Applied egg-rr33.6%
pow-pow33.6%
metadata-eval33.6%
pow1/367.4%
flip3--67.3%
pow367.4%
add-cube-cbrt67.6%
+-commutative67.6%
rem-cube-cbrt68.4%
pow268.4%
+-commutative68.4%
pow268.4%
+-commutative68.4%
cbrt-unprod68.4%
Applied egg-rr68.4%
associate--l+99.4%
+-inverses99.4%
metadata-eval99.4%
+-commutative99.4%
associate-+l+99.4%
*-commutative99.4%
distribute-lft-in99.4%
*-rgt-identity99.4%
Simplified99.4%
if 1.35000000000000003e154 < x Initial program 4.9%
flip3--4.9%
div-inv4.9%
rem-cube-cbrt2.7%
rem-cube-cbrt4.9%
cbrt-unprod4.9%
pow24.9%
distribute-rgt-out4.9%
+-commutative4.9%
Applied egg-rr4.9%
associate-*r/4.9%
*-rgt-identity4.9%
+-commutative4.9%
associate--l+4.9%
+-inverses4.9%
metadata-eval4.9%
+-commutative4.9%
fma-def4.9%
+-commutative4.9%
+-commutative4.9%
Simplified4.9%
pow1/34.9%
pow-pow91.3%
metadata-eval91.3%
Applied egg-rr91.3%
Final simplification87.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= x -1.32e+154)
(/ 1.0 (fma (cbrt x) t_1 1.0))
(if (<= x 1.35e+154)
(/ 1.0 (+ (pow t_0 2.0) (+ (pow (cbrt x) 2.0) (cbrt (+ x (* x x))))))
(/ 1.0 (fma (cbrt x) t_1 (pow (+ 1.0 x) 0.6666666666666666)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) + t_0;
double tmp;
if (x <= -1.32e+154) {
tmp = 1.0 / fma(cbrt(x), t_1, 1.0);
} else if (x <= 1.35e+154) {
tmp = 1.0 / (pow(t_0, 2.0) + (pow(cbrt(x), 2.0) + cbrt((x + (x * x)))));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (x <= -1.32e+154) tmp = Float64(1.0 / fma(cbrt(x), t_1, 1.0)); elseif (x <= 1.35e+154) tmp = Float64(1.0 / Float64((t_0 ^ 2.0) + Float64((cbrt(x) ^ 2.0) + cbrt(Float64(x + Float64(x * x)))))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[x, -1.32e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} + t_0\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, 1\right)}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{{t_0}^{2} + \left({\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x + x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1.31999999999999998e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.7%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
Taylor expanded in x around 0 20.0%
if -1.31999999999999998e154 < x < 1.35000000000000003e154Initial program 67.4%
add-log-exp67.3%
Applied egg-rr67.3%
add-log-exp67.4%
flip3--67.3%
rem-cube-cbrt67.6%
rem-cube-cbrt68.4%
div-sub67.5%
Applied egg-rr67.5%
div-sub68.4%
associate--l+99.4%
+-inverses99.4%
metadata-eval99.4%
*-commutative99.4%
distribute-lft-in99.4%
rem-cube-cbrt99.4%
metadata-eval99.4%
cube-prod99.4%
*-rgt-identity99.4%
rem-cube-cbrt99.4%
Simplified99.4%
if 1.35000000000000003e154 < x Initial program 4.9%
flip3--4.9%
div-inv4.9%
rem-cube-cbrt2.7%
rem-cube-cbrt4.9%
cbrt-unprod4.9%
pow24.9%
distribute-rgt-out4.9%
+-commutative4.9%
Applied egg-rr4.9%
associate-*r/4.9%
*-rgt-identity4.9%
+-commutative4.9%
associate--l+4.9%
+-inverses4.9%
metadata-eval4.9%
+-commutative4.9%
fma-def4.9%
+-commutative4.9%
+-commutative4.9%
Simplified4.9%
pow1/34.9%
pow-pow91.3%
metadata-eval91.3%
Applied egg-rr91.3%
Final simplification87.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.32e+154)
(/ 1.0 (fma (cbrt x) t_0 1.0))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (* x x))))
(/ 1.0 (fma (cbrt x) t_0 (pow (+ 1.0 x) 0.6666666666666666)))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= -1.32e+154) {
tmp = 1.0 / fma(cbrt(x), t_0, 1.0);
} else if (x <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt((x * x)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= -1.32e+154) tmp = Float64(1.0 / fma(cbrt(x), t_0, 1.0)); elseif (x <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt(Float64(x * x)))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.32e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1.31999999999999998e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.7%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
Taylor expanded in x around 0 20.0%
if -1.31999999999999998e154 < x < -1Initial program 9.2%
flip3--9.2%
div-inv9.2%
rem-cube-cbrt10.1%
rem-cube-cbrt11.5%
cbrt-unprod11.6%
pow211.6%
distribute-rgt-out11.6%
+-commutative11.6%
Applied egg-rr11.6%
associate-*r/11.6%
*-rgt-identity11.6%
+-commutative11.6%
associate--l+98.8%
+-inverses98.8%
metadata-eval98.8%
+-commutative98.8%
fma-def98.8%
+-commutative98.8%
+-commutative98.8%
Simplified98.8%
pow1/394.4%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 90.2%
unpow1/394.6%
unpow294.6%
Simplified94.6%
if -1 < x Initial program 70.2%
flip3--70.2%
div-inv70.2%
rem-cube-cbrt70.0%
rem-cube-cbrt70.9%
cbrt-unprod70.9%
pow270.9%
distribute-rgt-out70.9%
+-commutative70.9%
Applied egg-rr70.9%
associate-*r/70.9%
*-rgt-identity70.9%
+-commutative70.9%
associate--l+86.8%
+-inverses86.8%
metadata-eval86.8%
+-commutative86.8%
fma-def86.9%
+-commutative86.9%
+-commutative86.9%
Simplified86.9%
pow1/386.1%
pow-pow97.8%
metadata-eval97.8%
Applied egg-rr97.8%
Final simplification86.7%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (cbrt (/ 1.0 (* x x))) t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x)) - Math.cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) tmp = 0.0 if (t_0 <= 0.0) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = t_0; end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+53.3%
+-inverses53.3%
metadata-eval53.3%
+-commutative53.3%
fma-def53.3%
+-commutative53.3%
+-commutative53.3%
Simplified53.3%
pow1/350.9%
pow-pow42.0%
metadata-eval42.0%
Applied egg-rr42.0%
Taylor expanded in x around inf 11.5%
unpow1/311.5%
unpow211.5%
Simplified11.5%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
Final simplification56.2%
(FPCore (x)
:precision binary64
(if (or (<= x -0.96) (not (<= x 1.7)))
(cbrt (/ 1.0 (* x x)))
(-
(+ 1.0 (* x (+ 0.3333333333333333 (* x -0.1111111111111111))))
(cbrt x))))
double code(double x) {
double tmp;
if ((x <= -0.96) || !(x <= 1.7)) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.96) || !(x <= 1.7)) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.96) || !(x <= 1.7)) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = Float64(Float64(1.0 + Float64(x * Float64(0.3333333333333333 + Float64(x * -0.1111111111111111)))) - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.96], N[Not[LessEqual[x, 1.7]], $MachinePrecision]], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[(1.0 + N[(x * N[(0.3333333333333333 + N[(x * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.96 \lor \neg \left(x \leq 1.7\right):\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(0.3333333333333333 + x \cdot -0.1111111111111111\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -0.95999999999999996 or 1.69999999999999996 < x Initial program 8.3%
flip3--8.3%
div-inv8.3%
rem-cube-cbrt8.0%
rem-cube-cbrt9.9%
cbrt-unprod9.9%
pow29.9%
distribute-rgt-out9.9%
+-commutative9.9%
Applied egg-rr9.9%
associate-*r/9.9%
*-rgt-identity9.9%
+-commutative9.9%
associate--l+56.0%
+-inverses56.0%
metadata-eval56.0%
+-commutative56.0%
fma-def56.1%
+-commutative56.1%
+-commutative56.1%
Simplified56.1%
pow1/353.8%
pow-pow43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in x around inf 11.9%
unpow1/311.9%
unpow211.9%
Simplified11.9%
if -0.95999999999999996 < x < 1.69999999999999996Initial program 99.9%
Taylor expanded in x around 0 98.3%
+-commutative98.3%
unpow298.3%
associate-*r*98.3%
distribute-rgt-out98.3%
*-commutative98.3%
Simplified98.3%
Final simplification53.7%
(FPCore (x) :precision binary64 (if (or (<= x -0.95) (not (<= x 2.8))) (cbrt (/ 1.0 (* x x))) (+ 1.0 (- (* x 0.3333333333333333) (cbrt x)))))
double code(double x) {
double tmp;
if ((x <= -0.95) || !(x <= 2.8)) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 + ((x * 0.3333333333333333) - cbrt(x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.95) || !(x <= 2.8)) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 + ((x * 0.3333333333333333) - Math.cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.95) || !(x <= 2.8)) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = Float64(1.0 + Float64(Float64(x * 0.3333333333333333) - cbrt(x))); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.95], N[Not[LessEqual[x, 2.8]], $MachinePrecision]], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(1.0 + N[(N[(x * 0.3333333333333333), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.95 \lor \neg \left(x \leq 2.8\right):\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right)\\
\end{array}
\end{array}
if x < -0.94999999999999996 or 2.7999999999999998 < x Initial program 8.3%
flip3--8.3%
div-inv8.3%
rem-cube-cbrt8.0%
rem-cube-cbrt9.9%
cbrt-unprod9.9%
pow29.9%
distribute-rgt-out9.9%
+-commutative9.9%
Applied egg-rr9.9%
associate-*r/9.9%
*-rgt-identity9.9%
+-commutative9.9%
associate--l+56.0%
+-inverses56.0%
metadata-eval56.0%
+-commutative56.0%
fma-def56.1%
+-commutative56.1%
+-commutative56.1%
Simplified56.1%
pow1/353.8%
pow-pow43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in x around inf 11.9%
unpow1/311.9%
unpow211.9%
Simplified11.9%
if -0.94999999999999996 < x < 2.7999999999999998Initial program 99.9%
add-sqr-sqrt48.3%
pow248.3%
pow1/348.3%
sqrt-pow148.3%
metadata-eval48.3%
Applied egg-rr48.3%
Taylor expanded in x around 0 47.7%
unpow1/397.3%
associate--l+97.3%
*-commutative97.3%
Simplified97.3%
Final simplification53.2%
(FPCore (x) :precision binary64 (if (or (<= x -0.44) (not (<= x 0.8))) (cbrt (/ 1.0 (* x x))) (- 1.0 (cbrt x))))
double code(double x) {
double tmp;
if ((x <= -0.44) || !(x <= 0.8)) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.44) || !(x <= 0.8)) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.44) || !(x <= 0.8)) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = Float64(1.0 - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.44], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.44 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -0.440000000000000002 or 0.80000000000000004 < x Initial program 8.3%
flip3--8.3%
div-inv8.3%
rem-cube-cbrt8.0%
rem-cube-cbrt9.9%
cbrt-unprod9.9%
pow29.9%
distribute-rgt-out9.9%
+-commutative9.9%
Applied egg-rr9.9%
associate-*r/9.9%
*-rgt-identity9.9%
+-commutative9.9%
associate--l+56.0%
+-inverses56.0%
metadata-eval56.0%
+-commutative56.0%
fma-def56.1%
+-commutative56.1%
+-commutative56.1%
Simplified56.1%
pow1/353.8%
pow-pow43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in x around inf 11.9%
unpow1/311.9%
unpow211.9%
Simplified11.9%
if -0.440000000000000002 < x < 0.80000000000000004Initial program 99.9%
add-sqr-sqrt48.3%
pow248.3%
pow1/348.3%
sqrt-pow148.3%
metadata-eval48.3%
Applied egg-rr48.3%
Taylor expanded in x around 0 47.1%
unpow1/395.6%
Simplified95.6%
Final simplification52.4%
(FPCore (x) :precision binary64 (- 1.0 (cbrt x)))
double code(double x) {
return 1.0 - cbrt(x);
}
public static double code(double x) {
return 1.0 - Math.cbrt(x);
}
function code(x) return Float64(1.0 - cbrt(x)) end
code[x_] := N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt[3]{x}
\end{array}
Initial program 52.7%
add-sqr-sqrt25.8%
pow225.8%
pow1/326.1%
sqrt-pow126.1%
metadata-eval26.1%
Applied egg-rr26.1%
Taylor expanded in x around 0 23.2%
unpow1/348.2%
Simplified48.2%
Final simplification48.2%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 52.7%
Taylor expanded in x around inf 3.6%
Final simplification3.6%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 52.7%
Taylor expanded in x around 0 47.5%
Final simplification47.5%
herbie shell --seed 2023278
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))