
(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 (+ x 1.0))) (t_1 (+ (cbrt x) t_0)))
(if (<= x 4e+17)
(/
1.0
(fma
(cbrt x)
t_1
(*
(pow (sqrt (exp 0.6666666666666666)) (log1p x))
(pow (cbrt t_0) 3.0))))
(/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
double t_1 = cbrt(x) + t_0;
double tmp;
if (x <= 4e+17) {
tmp = 1.0 / fma(cbrt(x), t_1, (pow(sqrt(exp(0.6666666666666666)), log1p(x)) * pow(cbrt(t_0), 3.0)));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (x <= 4e+17) tmp = Float64(1.0 / fma(cbrt(x), t_1, Float64((sqrt(exp(0.6666666666666666)) ^ log1p(x)) * (cbrt(t_0) ^ 3.0)))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, (cbrt(x) ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[x, 4e+17], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[(N[Power[N[Sqrt[N[Exp[0.6666666666666666], $MachinePrecision]], $MachinePrecision], N[Log[1 + x], $MachinePrecision]], $MachinePrecision] * N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
t_1 := \sqrt[3]{x} + t\_0\\
\mathbf{if}\;x \leq 4 \cdot 10^{+17}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_1, {\left(\sqrt{e^{0.6666666666666666}}\right)}^{\left(\mathsf{log1p}\left(x\right)\right)} \cdot {\left(\sqrt[3]{t\_0}\right)}^{3}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\end{array}
\end{array}
if x < 4e17Initial program 53.3%
flip3--53.3%
div-inv53.4%
rem-cube-cbrt54.6%
rem-cube-cbrt91.7%
+-commutative91.7%
distribute-rgt-out91.7%
+-commutative91.7%
fma-define91.7%
add-exp-log91.7%
Applied egg-rr91.6%
associate-*r/91.6%
*-rgt-identity91.6%
+-commutative91.6%
associate--l+98.3%
+-inverses98.3%
metadata-eval98.3%
+-commutative98.3%
exp-prod97.2%
Simplified97.2%
add-sqr-sqrt97.2%
unpow-prod-down98.3%
Applied egg-rr98.3%
add-exp-log98.5%
log-pow98.4%
log1p-undefine98.4%
+-commutative98.4%
pow1/298.4%
log-pow98.4%
rem-log-exp98.4%
metadata-eval98.4%
pow-to-exp98.3%
pow1/398.6%
expm1-log1p-u98.4%
Applied egg-rr98.4%
add-cube-cbrt98.6%
pow398.8%
expm1-log1p-u98.9%
Applied egg-rr98.9%
if 4e17 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.5%
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.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 48.3%
pow1/346.0%
unpow246.0%
unpow-prod-down92.7%
metadata-eval92.7%
pow-pow92.7%
metadata-eval92.7%
pow-pow92.7%
*-un-lft-identity92.7%
pow292.7%
pow-pow92.7%
metadata-eval92.7%
pow1/398.5%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Final simplification98.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ x 1.0))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow (cbrt x) 2.0)))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) t_0)
(* (pow (sqrt (exp 0.6666666666666666)) (log1p x)) t_0))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(cbrt(x), 2.0));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), (pow(sqrt(exp(0.6666666666666666)), log1p(x)) * t_0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (cbrt(x) ^ 2.0))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), Float64((sqrt(exp(0.6666666666666666)) ^ log1p(x)) * t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-11], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[Power[N[Sqrt[N[Exp[0.6666666666666666], $MachinePrecision]], $MachinePrecision], N[Log[1 + x], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {\left(\sqrt{e^{0.6666666666666666}}\right)}^{\left(\mathsf{log1p}\left(x\right)\right)} \cdot t\_0\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt3.6%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-define5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.3%
Simplified92.3%
Taylor expanded in x around inf 48.9%
pow1/346.6%
unpow246.6%
unpow-prod-down92.7%
metadata-eval92.7%
pow-pow92.7%
metadata-eval92.7%
pow-pow92.7%
*-un-lft-identity92.7%
pow292.7%
pow-pow92.7%
metadata-eval92.7%
pow1/398.5%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 63.4%
flip3--63.4%
div-inv63.4%
rem-cube-cbrt65.7%
rem-cube-cbrt98.6%
+-commutative98.6%
distribute-rgt-out98.6%
+-commutative98.6%
fma-define98.6%
add-exp-log98.5%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
+-commutative98.5%
associate--l+98.5%
+-inverses98.5%
metadata-eval98.5%
+-commutative98.5%
exp-prod97.3%
Simplified97.3%
add-sqr-sqrt97.3%
unpow-prod-down98.7%
Applied egg-rr98.7%
add-exp-log99.0%
log-pow98.7%
log1p-undefine98.7%
+-commutative98.7%
pow1/298.7%
log-pow98.7%
rem-log-exp98.7%
metadata-eval98.7%
pow-to-exp98.5%
pow1/398.8%
Applied egg-rr98.8%
Final simplification98.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ x 1.0))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow (cbrt x) 2.0)))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) t_0)
(pow (sqrt (exp 0.6666666666666666)) (* (log1p x) 2.0)))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(cbrt(x), 2.0));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(sqrt(exp(0.6666666666666666)), (log1p(x) * 2.0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (cbrt(x) ^ 2.0))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (sqrt(exp(0.6666666666666666)) ^ Float64(log1p(x) * 2.0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-11], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[Sqrt[N[Exp[0.6666666666666666], $MachinePrecision]], $MachinePrecision], N[(N[Log[1 + x], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {\left(\sqrt{e^{0.6666666666666666}}\right)}^{\left(\mathsf{log1p}\left(x\right) \cdot 2\right)}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt3.6%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-define5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.3%
Simplified92.3%
Taylor expanded in x around inf 48.9%
pow1/346.6%
unpow246.6%
unpow-prod-down92.7%
metadata-eval92.7%
pow-pow92.7%
metadata-eval92.7%
pow-pow92.7%
*-un-lft-identity92.7%
pow292.7%
pow-pow92.7%
metadata-eval92.7%
pow1/398.5%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 63.4%
flip3--63.4%
div-inv63.4%
rem-cube-cbrt65.7%
rem-cube-cbrt98.6%
+-commutative98.6%
distribute-rgt-out98.6%
+-commutative98.6%
fma-define98.6%
add-exp-log98.5%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
+-commutative98.5%
associate--l+98.5%
+-inverses98.5%
metadata-eval98.5%
+-commutative98.5%
exp-prod97.3%
Simplified97.3%
add-sqr-sqrt97.3%
unpow-prod-down98.7%
Applied egg-rr98.7%
pow-sqr98.6%
Simplified98.6%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ x 1.0))) (t_1 (+ (cbrt x) t_0)))
(if (<= x 3e+17)
(/
1.0
(fma
(cbrt x)
t_1
(* (exp (* (log1p x) 0.3333333333333333)) (expm1 (log1p t_0)))))
(/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
double t_1 = cbrt(x) + t_0;
double tmp;
if (x <= 3e+17) {
tmp = 1.0 / fma(cbrt(x), t_1, (exp((log1p(x) * 0.3333333333333333)) * expm1(log1p(t_0))));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (x <= 3e+17) tmp = Float64(1.0 / fma(cbrt(x), t_1, Float64(exp(Float64(log1p(x) * 0.3333333333333333)) * expm1(log1p(t_0))))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, (cbrt(x) ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[x, 3e+17], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
t_1 := \sqrt[3]{x} + t\_0\\
\mathbf{if}\;x \leq 3 \cdot 10^{+17}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_1, e^{\mathsf{log1p}\left(x\right) \cdot 0.3333333333333333} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\end{array}
\end{array}
if x < 3e17Initial program 53.3%
flip3--53.3%
div-inv53.4%
rem-cube-cbrt54.6%
rem-cube-cbrt91.7%
+-commutative91.7%
distribute-rgt-out91.7%
+-commutative91.7%
fma-define91.7%
add-exp-log91.7%
Applied egg-rr91.6%
associate-*r/91.6%
*-rgt-identity91.6%
+-commutative91.6%
associate--l+98.3%
+-inverses98.3%
metadata-eval98.3%
+-commutative98.3%
exp-prod97.2%
Simplified97.2%
add-sqr-sqrt97.2%
unpow-prod-down98.3%
Applied egg-rr98.3%
add-exp-log98.5%
log-pow98.4%
log1p-undefine98.4%
+-commutative98.4%
pow1/298.4%
log-pow98.4%
rem-log-exp98.4%
metadata-eval98.4%
pow-to-exp98.3%
pow1/398.6%
expm1-log1p-u98.4%
Applied egg-rr98.4%
add-exp-log98.8%
log-pow98.8%
log1p-undefine98.8%
+-commutative98.8%
pow1/298.8%
log-pow98.8%
rem-log-exp98.8%
metadata-eval98.8%
+-commutative98.8%
log1p-undefine98.8%
Applied egg-rr98.8%
if 3e17 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.5%
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.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 48.3%
pow1/346.0%
unpow246.0%
unpow-prod-down92.7%
metadata-eval92.7%
pow-pow92.7%
metadata-eval92.7%
pow-pow92.7%
*-un-lft-identity92.7%
pow292.7%
pow-pow92.7%
metadata-eval92.7%
pow1/398.5%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Final simplification98.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ x 1.0))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow (cbrt x) 2.0)))
(/ (- (+ x 1.0) x) (+ (* (cbrt x) (+ (cbrt x) t_0)) (pow t_0 2.0))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(cbrt(x), 2.0));
} else {
tmp = ((x + 1.0) - x) / ((cbrt(x) * (cbrt(x) + t_0)) + pow(t_0, 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (cbrt(x) ^ 2.0))); else tmp = Float64(Float64(Float64(x + 1.0) - x) / Float64(Float64(cbrt(x) * Float64(cbrt(x) + t_0)) + (t_0 ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-11], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 1.0), $MachinePrecision] - x), $MachinePrecision] / N[(N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) - x}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right) + {t\_0}^{2}}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt3.6%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-define5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.3%
Simplified92.3%
Taylor expanded in x around inf 48.9%
pow1/346.6%
unpow246.6%
unpow-prod-down92.7%
metadata-eval92.7%
pow-pow92.7%
metadata-eval92.7%
pow-pow92.7%
*-un-lft-identity92.7%
pow292.7%
pow-pow92.7%
metadata-eval92.7%
pow1/398.5%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 63.4%
add-sqr-sqrt63.5%
pow263.5%
pow1/362.3%
sqrt-pow162.1%
metadata-eval62.1%
Applied egg-rr62.1%
metadata-eval62.1%
sqrt-pow162.3%
pow1/363.5%
Applied egg-rr63.5%
unpow263.5%
add-sqr-sqrt63.4%
flip3--63.4%
pow367.3%
add-cube-cbrt65.7%
rem-cube-cbrt98.6%
distribute-rgt-in98.6%
+-commutative98.6%
+-commutative98.6%
+-commutative98.6%
Applied egg-rr98.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ x 1.0))) (t_1 (* (cbrt x) (+ (cbrt x) t_0))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (+ (pow (cbrt x) 2.0) t_1))
(/ (- (+ x 1.0) x) (+ t_1 (pow t_0 2.0))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
double t_1 = cbrt(x) * (cbrt(x) + t_0);
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / (pow(cbrt(x), 2.0) + t_1);
} else {
tmp = ((x + 1.0) - x) / (t_1 + pow(t_0, 2.0));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((x + 1.0));
double t_1 = Math.cbrt(x) * (Math.cbrt(x) + t_0);
double tmp;
if ((t_0 - Math.cbrt(x)) <= 5e-11) {
tmp = 1.0 / (Math.pow(Math.cbrt(x), 2.0) + t_1);
} else {
tmp = ((x + 1.0) - x) / (t_1 + Math.pow(t_0, 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) t_1 = Float64(cbrt(x) * Float64(cbrt(x) + t_0)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / Float64((cbrt(x) ^ 2.0) + t_1)); else tmp = Float64(Float64(Float64(x + 1.0) - x) / Float64(t_1 + (t_0 ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-11], N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 1.0), $MachinePrecision] - x), $MachinePrecision] / N[(t$95$1 + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
t_1 := \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) - x}{t\_1 + {t\_0}^{2}}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt3.6%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-define5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.3%
Simplified92.3%
Taylor expanded in x around inf 48.9%
pow1/346.6%
unpow246.6%
unpow-prod-down92.7%
metadata-eval92.7%
pow-pow92.7%
metadata-eval92.7%
pow-pow92.7%
*-un-lft-identity92.7%
pow292.7%
pow-pow92.7%
metadata-eval92.7%
pow1/398.5%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
fma-undefine98.5%
+-commutative98.5%
+-commutative98.5%
+-commutative98.5%
Applied egg-rr98.5%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 63.4%
add-sqr-sqrt63.5%
pow263.5%
pow1/362.3%
sqrt-pow162.1%
metadata-eval62.1%
Applied egg-rr62.1%
metadata-eval62.1%
sqrt-pow162.3%
pow1/363.5%
Applied egg-rr63.5%
unpow263.5%
add-sqr-sqrt63.4%
flip3--63.4%
pow367.3%
add-cube-cbrt65.7%
rem-cube-cbrt98.6%
distribute-rgt-in98.6%
+-commutative98.6%
+-commutative98.6%
+-commutative98.6%
Applied egg-rr98.6%
(FPCore (x) :precision binary64 (/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) (+ (cbrt x) (cbrt (+ x 1.0)))))))
double code(double x) {
return 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * (cbrt(x) + cbrt((x + 1.0)))));
}
public static double code(double x) {
return 1.0 / (Math.pow(Math.cbrt(x), 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((x + 1.0)))));
}
function code(x) return Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(x + 1.0)))))) end
code[x_] := N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{x + 1}\right)}
\end{array}
Initial program 6.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt6.3%
rem-cube-cbrt9.0%
+-commutative9.0%
distribute-rgt-out9.0%
+-commutative9.0%
fma-define9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate-*r/9.0%
*-rgt-identity9.0%
+-commutative9.0%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Taylor expanded in x around inf 49.2%
pow1/347.0%
unpow247.0%
unpow-prod-down91.1%
metadata-eval91.1%
pow-pow91.1%
metadata-eval91.1%
pow-pow91.1%
*-un-lft-identity91.1%
pow291.1%
pow-pow91.1%
metadata-eval91.1%
pow1/396.7%
Applied egg-rr96.7%
*-lft-identity96.7%
Simplified96.7%
fma-undefine96.6%
+-commutative96.6%
+-commutative96.6%
+-commutative96.6%
Applied egg-rr96.6%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ x 1.0))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((x + 1.0))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(x + 1.0))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x + 1}, 1\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.1%
Taylor expanded in x around inf 94.8%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.0%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+91.7%
+-inverses91.7%
metadata-eval91.7%
+-commutative91.7%
exp-prod91.2%
Simplified91.2%
Taylor expanded in x around 0 19.9%
Final simplification56.8%
(FPCore (x) :precision binary64 (/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) (cbrt (+ x 1.0)))))))
double code(double x) {
return 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + cbrt((x + 1.0)))));
}
public static double code(double x) {
return 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + Math.cbrt((x + 1.0)))));
}
function code(x) return Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + cbrt(Float64(x + 1.0)))))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + \sqrt[3]{x + 1}\right)\right)}
\end{array}
Initial program 6.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt6.3%
rem-cube-cbrt9.0%
+-commutative9.0%
distribute-rgt-out9.0%
+-commutative9.0%
fma-define9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate-*r/9.0%
*-rgt-identity9.0%
+-commutative9.0%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Taylor expanded in x around inf 49.2%
pow1/347.0%
unpow247.0%
unpow-prod-down91.1%
metadata-eval91.1%
pow-pow91.1%
metadata-eval91.1%
pow-pow91.1%
*-un-lft-identity91.1%
pow291.1%
pow-pow91.1%
metadata-eval91.1%
pow1/396.7%
Applied egg-rr96.7%
*-lft-identity96.7%
Simplified96.7%
fma-undefine96.6%
unpow296.6%
distribute-lft-out96.6%
+-commutative96.6%
+-commutative96.6%
Applied egg-rr96.6%
Final simplification96.6%
(FPCore (x) :precision binary64 (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
double code(double x) {
return 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
public static double code(double x) {
return 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
function code(x) return Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))) end
code[x_] := N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}
\end{array}
Initial program 6.9%
Taylor expanded in x around inf 49.1%
(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}
Initial program 6.9%
(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 6.9%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.3%
fabs-neg5.3%
unpow1/35.3%
metadata-eval5.3%
pow-sqr5.3%
fabs-sqr5.3%
pow-sqr5.3%
metadata-eval5.3%
unpow1/35.3%
Simplified5.3%
(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 2024101
(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)))