
(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 12 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))))
(if (<= x 2e+23)
(/
1.0
(fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 2e+23) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 2e+23) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), cbrt((Float64(1.0 + x) ^ 2.0)))); else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 2e+23], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 1.9999999999999998e23Initial program 45.6%
flip3--47.6%
div-inv47.6%
rem-cube-cbrt53.8%
rem-cube-cbrt69.4%
+-commutative69.4%
distribute-rgt-out69.3%
+-commutative69.3%
fma-define69.2%
add-exp-log69.1%
Applied egg-rr69.0%
associate-*r/69.0%
*-rgt-identity69.0%
+-commutative69.0%
associate--l+97.8%
+-inverses97.8%
metadata-eval97.8%
+-commutative97.8%
exp-prod97.4%
Simplified97.4%
pow-exp97.8%
*-commutative97.8%
log1p-undefine97.8%
+-commutative97.8%
exp-to-pow97.9%
metadata-eval97.9%
metadata-eval97.9%
pow-sqr97.9%
metadata-eval97.9%
pow1/398.5%
metadata-eval98.5%
pow1/398.6%
cbrt-unprod99.0%
pow299.0%
Applied egg-rr99.0%
if 1.9999999999999998e23 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.3%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-define4.2%
add-exp-log4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+92.7%
+-inverses92.7%
metadata-eval92.7%
+-commutative92.7%
exp-prod91.9%
Simplified91.9%
Taylor expanded in x around inf 91.9%
Taylor expanded in x around inf 98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (sqrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (* t_0 t_0)) (pow (cbrt (+ 1.0 x)) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + (t_0 * t_0)), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(t_0 * t_0)), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt{1 + x}}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0 \cdot t\_0, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 8.5%
flip3--8.7%
div-inv8.7%
rem-cube-cbrt8.4%
rem-cube-cbrt10.9%
+-commutative10.9%
distribute-rgt-out10.9%
+-commutative10.9%
fma-define10.8%
add-exp-log10.8%
Applied egg-rr10.8%
associate-*r/10.8%
*-rgt-identity10.8%
+-commutative10.8%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
metadata-eval93.1%
pow1/394.5%
metadata-eval94.5%
pow1/398.5%
Applied egg-rr98.5%
pow1/394.5%
+-commutative94.5%
add-sqr-sqrt94.5%
metadata-eval94.5%
unpow-prod-down94.5%
+-commutative94.5%
add-sqr-sqrt94.5%
hypot-1-def94.5%
metadata-eval94.5%
+-commutative94.5%
add-sqr-sqrt94.5%
hypot-1-def94.5%
metadata-eval94.5%
Applied egg-rr94.5%
unpow1/395.8%
hypot-undefine95.8%
metadata-eval95.8%
rem-square-sqrt95.8%
unpow1/398.5%
hypot-undefine98.5%
metadata-eval98.5%
rem-square-sqrt98.5%
Simplified98.5%
pow298.5%
Applied egg-rr98.5%
Final simplification98.5%
(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 8.5%
flip3--8.7%
div-inv8.7%
rem-cube-cbrt8.4%
rem-cube-cbrt10.9%
+-commutative10.9%
distribute-rgt-out10.9%
+-commutative10.9%
fma-define10.8%
add-exp-log10.8%
Applied egg-rr10.8%
associate-*r/10.8%
*-rgt-identity10.8%
+-commutative10.8%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
metadata-eval93.1%
pow1/394.5%
metadata-eval94.5%
pow1/398.5%
Applied egg-rr98.5%
pow298.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 x))))
(if (<= x 1e+15)
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ 1.0 x)))
(pow (+ 1.0 x) 0.6666666666666666)))
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 1e+15) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((1.0 + x), 0.6666666666666666));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 1e+15) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 1e+15], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 10^{+15}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 1e15Initial program 68.1%
flip3--71.2%
div-inv71.1%
rem-cube-cbrt72.8%
rem-cube-cbrt98.8%
+-commutative98.8%
distribute-rgt-out98.7%
+-commutative98.7%
fma-define98.6%
add-exp-log98.5%
Applied egg-rr98.3%
associate-*r/98.3%
*-rgt-identity98.3%
+-commutative98.3%
associate--l+98.3%
+-inverses98.3%
metadata-eval98.3%
+-commutative98.3%
exp-prod98.4%
Simplified98.4%
pow-exp98.3%
*-commutative98.3%
log1p-undefine98.3%
+-commutative98.3%
exp-to-pow98.7%
metadata-eval98.7%
metadata-eval98.7%
pow-sqr98.6%
metadata-eval98.6%
pow1/399.1%
metadata-eval99.1%
pow1/398.6%
Applied egg-rr98.6%
pow298.6%
pow1/398.6%
pow-pow98.7%
metadata-eval98.7%
Applied egg-rr98.7%
if 1e15 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.6%
+-commutative4.6%
distribute-rgt-out4.6%
+-commutative4.6%
fma-define4.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
+-commutative4.6%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.0%
Simplified92.0%
Taylor expanded in x around inf 92.0%
Taylor expanded in x around inf 98.8%
Final simplification98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 x))))
(if (<= x 52000000.0)
(pow
(cbrt
(+
(pow (+ 1.0 x) 0.3333333333333333)
(- 0.0 (pow x 0.3333333333333333))))
3.0)
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 52000000.0) {
tmp = pow(cbrt((pow((1.0 + x), 0.3333333333333333) + (0.0 - pow(x, 0.3333333333333333)))), 3.0);
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 / x));
double tmp;
if (x <= 52000000.0) {
tmp = Math.pow(Math.cbrt((Math.pow((1.0 + x), 0.3333333333333333) + (0.0 - Math.pow(x, 0.3333333333333333)))), 3.0);
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 52000000.0) tmp = cbrt(Float64((Float64(1.0 + x) ^ 0.3333333333333333) + Float64(0.0 - (x ^ 0.3333333333333333)))) ^ 3.0; else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 52000000.0], N[Power[N[Power[N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] + N[(0.0 - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 52000000:\\
\;\;\;\;{\left(\sqrt[3]{{\left(1 + x\right)}^{0.3333333333333333} + \left(0 - {x}^{0.3333333333333333}\right)}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 5.2e7Initial program 78.1%
add-cube-cbrt78.3%
pow378.3%
Applied egg-rr78.3%
pow1/376.4%
Applied egg-rr76.4%
pow1/379.5%
Applied egg-rr79.5%
if 5.2e7 < x Initial program 5.0%
flip3--5.0%
div-inv5.0%
rem-cube-cbrt4.9%
rem-cube-cbrt6.5%
+-commutative6.5%
distribute-rgt-out6.5%
+-commutative6.5%
fma-define6.5%
add-exp-log6.5%
Applied egg-rr6.5%
associate-*r/6.5%
*-rgt-identity6.5%
+-commutative6.5%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 91.7%
Taylor expanded in x around inf 98.3%
Final simplification97.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 x))))
(if (<= x 25000000.0)
(pow E (log (- (cbrt (+ 1.0 x)) (cbrt x))))
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 25000000.0) {
tmp = pow(((double) M_E), log((cbrt((1.0 + x)) - cbrt(x))));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 / x));
double tmp;
if (x <= 25000000.0) {
tmp = Math.pow(Math.E, Math.log((Math.cbrt((1.0 + x)) - Math.cbrt(x))));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 25000000.0) tmp = exp(1) ^ log(Float64(cbrt(Float64(1.0 + x)) - cbrt(x))); else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 25000000.0], N[Power[E, N[Log[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;{e}^{\log \left(\sqrt[3]{1 + x} - \sqrt[3]{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
expm1-log1p-u77.5%
expm1-undefine77.8%
Applied egg-rr77.8%
expm1-define77.5%
Simplified77.5%
expm1-log1p-u80.1%
rem-cube-cbrt80.3%
exp-to-pow80.5%
*-un-lft-identity80.5%
exp-prod80.3%
add-log-exp80.3%
exp-to-pow80.2%
rem-cube-cbrt80.1%
Applied egg-rr80.1%
exp-1-e80.1%
+-commutative80.1%
Simplified80.1%
if 2.5e7 < x Initial program 5.2%
flip3--5.2%
div-inv5.2%
rem-cube-cbrt5.1%
rem-cube-cbrt6.9%
+-commutative6.9%
distribute-rgt-out6.9%
+-commutative6.9%
fma-define6.9%
add-exp-log6.9%
Applied egg-rr6.9%
associate-*r/6.9%
*-rgt-identity6.9%
+-commutative6.9%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 91.6%
Taylor expanded in x around inf 98.2%
Final simplification97.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 x))))
(if (<= x 25000000.0)
(pow (cbrt (- (cbrt (+ 1.0 x)) (cbrt x))) 3.0)
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 25000000.0) {
tmp = pow(cbrt((cbrt((1.0 + x)) - cbrt(x))), 3.0);
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 / x));
double tmp;
if (x <= 25000000.0) {
tmp = Math.pow(Math.cbrt((Math.cbrt((1.0 + x)) - Math.cbrt(x))), 3.0);
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 25000000.0) tmp = cbrt(Float64(cbrt(Float64(1.0 + x)) - cbrt(x))) ^ 3.0; else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 25000000.0], N[Power[N[Power[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;{\left(\sqrt[3]{\sqrt[3]{1 + x} - \sqrt[3]{x}}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
add-cube-cbrt80.3%
pow380.3%
Applied egg-rr80.3%
if 2.5e7 < x Initial program 5.2%
flip3--5.2%
div-inv5.2%
rem-cube-cbrt5.1%
rem-cube-cbrt6.9%
+-commutative6.9%
distribute-rgt-out6.9%
+-commutative6.9%
fma-define6.9%
add-exp-log6.9%
Applied egg-rr6.9%
associate-*r/6.9%
*-rgt-identity6.9%
+-commutative6.9%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 91.6%
Taylor expanded in x around inf 98.2%
Final simplification97.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 x))))
(if (<= x 25000000.0)
(- (cbrt (+ 1.0 x)) (cbrt x))
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 25000000.0) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 / x));
double tmp;
if (x <= 25000000.0) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 25000000.0) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 25000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
if 2.5e7 < x Initial program 5.2%
flip3--5.2%
div-inv5.2%
rem-cube-cbrt5.1%
rem-cube-cbrt6.9%
+-commutative6.9%
distribute-rgt-out6.9%
+-commutative6.9%
fma-define6.9%
add-exp-log6.9%
Applied egg-rr6.9%
associate-*r/6.9%
*-rgt-identity6.9%
+-commutative6.9%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 91.6%
Taylor expanded in x around inf 98.2%
Final simplification97.4%
(FPCore (x) :precision binary64 (if (<= x 25000000.0) (- (cbrt (+ 1.0 x)) (cbrt x)) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 25000000.0) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 25000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
if 2.5e7 < x Initial program 5.2%
Taylor expanded in x around inf 48.2%
Final simplification49.6%
(FPCore (x) :precision binary64 (- (cbrt (+ 1.0 x)) (cbrt x)))
double code(double x) {
return cbrt((1.0 + x)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} - \sqrt[3]{x}
\end{array}
Initial program 8.5%
Final simplification8.5%
(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 8.5%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.5%
fabs-neg5.5%
unpow1/35.5%
metadata-eval5.5%
pow-sqr5.5%
fabs-sqr5.5%
pow-sqr5.5%
metadata-eval5.5%
unpow1/35.5%
Simplified5.5%
Final simplification5.5%
(FPCore (x) :precision binary64 (- (cbrt x)))
double code(double x) {
return -cbrt(x);
}
public static double code(double x) {
return -Math.cbrt(x);
}
function code(x) return Float64(-cbrt(x)) end
code[x_] := (-N[Power[x, 1/3], $MachinePrecision])
\begin{array}{l}
\\
-\sqrt[3]{x}
\end{array}
Initial program 8.5%
Taylor expanded in x around 0 4.4%
*-commutative4.4%
Simplified4.4%
Taylor expanded in x around 0 1.8%
Simplified1.8%
Final simplification1.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ x 1.0)))) (/ 1.0 (+ (+ (* t_0 t_0) (* (cbrt x) t_0)) (* (cbrt x) (cbrt x))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
return 1.0 / (((t_0 * t_0) + (cbrt(x) * t_0)) + (cbrt(x) * cbrt(x)));
}
public static double code(double x) {
double t_0 = Math.cbrt((x + 1.0));
return 1.0 / (((t_0 * t_0) + (Math.cbrt(x) * t_0)) + (Math.cbrt(x) * Math.cbrt(x)));
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) return Float64(1.0 / Float64(Float64(Float64(t_0 * t_0) + Float64(cbrt(x) * t_0)) + Float64(cbrt(x) * cbrt(x)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
\frac{1}{\left(t\_0 \cdot t\_0 + \sqrt[3]{x} \cdot t\_0\right) + \sqrt[3]{x} \cdot \sqrt[3]{x}}
\end{array}
\end{array}
herbie shell --seed 2024079
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(/ 1.0 (+ (+ (* (cbrt (+ x 1.0)) (cbrt (+ x 1.0))) (* (cbrt x) (cbrt (+ x 1.0)))) (* (cbrt x) (cbrt x))))
(- (cbrt (+ x 1.0)) (cbrt x)))