
(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 13 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 (sqrt (+ 1.0 x)))) (t_1 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (* t_0 t_0)) (* t_1 t_1)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
double t_1 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + (t_0 * t_0)), (t_1 * t_1));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) t_1 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(t_0 * t_0)), Float64(t_1 * t_1))) end
code[x_] := Block[{t$95$0 = N[Power[N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = 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] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt{1 + x}}\\
t_1 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0 \cdot t\_0, t\_1 \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 6.6%
flip3--6.5%
div-inv6.5%
rem-cube-cbrt6.1%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
Applied egg-rr8.3%
associate-*r/8.3%
*-rgt-identity8.3%
+-commutative8.3%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
add-sqr-sqrt92.2%
unpow-prod-down93.6%
Applied egg-rr93.6%
pow-sqr93.6%
Simplified93.6%
sqr-pow93.6%
pow293.6%
pow-to-exp93.0%
*-commutative93.0%
associate-/l*93.0%
metadata-eval93.0%
*-commutative93.0%
*-un-lft-identity93.0%
pow1/293.0%
log-pow93.0%
rem-log-exp93.0%
metadata-eval93.0%
log1p-undefine93.0%
+-commutative93.0%
log-pow93.4%
add-exp-log92.8%
pow292.8%
unpow1/394.3%
Applied egg-rr98.4%
pow1/394.3%
+-commutative94.3%
add-sqr-sqrt94.3%
unpow-prod-down94.3%
+-commutative94.3%
add-sqr-sqrt94.3%
hypot-1-def94.3%
+-commutative94.3%
add-sqr-sqrt94.3%
hypot-1-def94.3%
Applied egg-rr94.3%
unpow1/395.7%
hypot-undefine95.7%
metadata-eval95.7%
rem-square-sqrt95.7%
unpow1/398.6%
hypot-undefine98.6%
metadata-eval98.6%
rem-square-sqrt98.6%
Simplified98.6%
Final simplification98.6%
(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 (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (fma (cbrt x) t_0 (exp (* (log1p 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, cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, exp((log1p(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, cbrt((Float64(1.0 + x) ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, exp(Float64(log1p(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 + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Exp[N[(N[Log[1 + x], $MachinePrecision] * 0.6666666666666666), $MachinePrecision]], $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, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_0, e^{\mathsf{log1p}\left(x\right) \cdot 0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.31999999999999998e154Initial program 8.4%
flip3--8.4%
div-inv8.4%
rem-cube-cbrt9.4%
rem-cube-cbrt12.0%
+-commutative12.0%
distribute-rgt-out12.0%
+-commutative12.0%
fma-define12.0%
add-exp-log11.9%
Applied egg-rr11.9%
associate-*r/11.9%
*-rgt-identity11.9%
+-commutative11.9%
associate--l+94.3%
+-inverses94.3%
metadata-eval94.3%
+-commutative94.3%
exp-prod93.6%
Simplified93.6%
add-sqr-sqrt93.6%
unpow-prod-down94.9%
Applied egg-rr94.9%
pow-sqr95.0%
Simplified95.0%
sqr-pow94.9%
pow294.9%
pow-to-exp94.3%
*-commutative94.3%
associate-/l*94.3%
metadata-eval94.3%
*-commutative94.3%
*-un-lft-identity94.3%
pow1/294.3%
log-pow94.3%
rem-log-exp94.3%
metadata-eval94.3%
log1p-undefine94.3%
+-commutative94.3%
log-pow94.5%
add-exp-log94.2%
pow294.2%
unpow1/395.6%
Applied egg-rr99.0%
if 1.31999999999999998e154 < 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.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.9%
Simplified90.9%
add-exp-log91.1%
log-pow91.8%
rem-log-exp91.8%
Applied egg-rr91.8%
Final simplification95.3%
(FPCore (x)
:precision binary64
(if (<= x 1.6e+231)
(pow
(/
(sqrt
(fma
0.3333333333333333
(pow (cbrt x) 4.0)
(* (cbrt x) -0.1111111111111111)))
x)
2.0)
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ 1.0 x)))
(exp (* (log1p x) 0.6666666666666666))))))
double code(double x) {
double tmp;
if (x <= 1.6e+231) {
tmp = pow((sqrt(fma(0.3333333333333333, pow(cbrt(x), 4.0), (cbrt(x) * -0.1111111111111111))) / x), 2.0);
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), exp((log1p(x) * 0.6666666666666666)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.6e+231) tmp = Float64(sqrt(fma(0.3333333333333333, (cbrt(x) ^ 4.0), Float64(cbrt(x) * -0.1111111111111111))) / x) ^ 2.0; else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), exp(Float64(log1p(x) * 0.6666666666666666)))); end return tmp end
code[x_] := If[LessEqual[x, 1.6e+231], N[Power[N[(N[Sqrt[N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], 4.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision], 2.0], $MachinePrecision], 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[Exp[N[(N[Log[1 + x], $MachinePrecision] * 0.6666666666666666), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{+231}:\\
\;\;\;\;{\left(\frac{\sqrt{\mathsf{fma}\left(0.3333333333333333, {\left(\sqrt[3]{x}\right)}^{4}, \sqrt[3]{x} \cdot -0.1111111111111111\right)}}{x}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, e^{\mathsf{log1p}\left(x\right) \cdot 0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.60000000000000016e231Initial program 7.1%
Taylor expanded in x around inf 26.6%
+-commutative26.6%
fma-define26.6%
Simplified26.6%
add-sqr-sqrt26.5%
pow226.5%
sqrt-div26.5%
sqrt-pow127.3%
metadata-eval27.3%
pow127.3%
Applied egg-rr27.3%
*-un-lft-identity27.3%
Applied egg-rr27.3%
*-lft-identity27.3%
unpow1/325.7%
exp-to-pow25.9%
*-commutative25.9%
exp-prod88.8%
*-commutative88.8%
associate-*l*88.8%
metadata-eval88.8%
exp-to-pow88.5%
metadata-eval88.5%
pow-plus91.4%
unpow1/397.6%
rem-3cbrt-rft96.4%
unpow296.4%
associate-*l*96.4%
unpow296.4%
pow-sqr96.4%
metadata-eval96.4%
Simplified96.4%
if 1.60000000000000016e231 < x Initial program 5.1%
flip3--5.1%
div-inv5.1%
rem-cube-cbrt3.1%
rem-cube-cbrt5.1%
+-commutative5.1%
distribute-rgt-out5.1%
+-commutative5.1%
fma-define5.1%
add-exp-log5.1%
Applied egg-rr5.1%
associate-*r/5.1%
*-rgt-identity5.1%
+-commutative5.1%
associate--l+91.5%
+-inverses91.5%
metadata-eval91.5%
+-commutative91.5%
exp-prod90.8%
Simplified90.8%
add-exp-log91.0%
log-pow91.5%
rem-log-exp91.5%
Applied egg-rr91.5%
Final simplification95.1%
(FPCore (x)
:precision binary64
(if (<= x 1.6e+231)
(pow
(/
(sqrt
(fma
0.3333333333333333
(pow (cbrt x) 4.0)
(* (cbrt x) -0.1111111111111111)))
x)
2.0)
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ 1.0 x)))
(pow (+ 1.0 x) 0.6666666666666666)))))
double code(double x) {
double tmp;
if (x <= 1.6e+231) {
tmp = pow((sqrt(fma(0.3333333333333333, pow(cbrt(x), 4.0), (cbrt(x) * -0.1111111111111111))) / x), 2.0);
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.6e+231) tmp = Float64(sqrt(fma(0.3333333333333333, (cbrt(x) ^ 4.0), Float64(cbrt(x) * -0.1111111111111111))) / x) ^ 2.0; else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := If[LessEqual[x, 1.6e+231], N[Power[N[(N[Sqrt[N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], 4.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision], 2.0], $MachinePrecision], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{+231}:\\
\;\;\;\;{\left(\frac{\sqrt{\mathsf{fma}\left(0.3333333333333333, {\left(\sqrt[3]{x}\right)}^{4}, \sqrt[3]{x} \cdot -0.1111111111111111\right)}}{x}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.60000000000000016e231Initial program 7.1%
Taylor expanded in x around inf 26.6%
+-commutative26.6%
fma-define26.6%
Simplified26.6%
add-sqr-sqrt26.5%
pow226.5%
sqrt-div26.5%
sqrt-pow127.3%
metadata-eval27.3%
pow127.3%
Applied egg-rr27.3%
*-un-lft-identity27.3%
Applied egg-rr27.3%
*-lft-identity27.3%
unpow1/325.7%
exp-to-pow25.9%
*-commutative25.9%
exp-prod88.8%
*-commutative88.8%
associate-*l*88.8%
metadata-eval88.8%
exp-to-pow88.5%
metadata-eval88.5%
pow-plus91.4%
unpow1/397.6%
rem-3cbrt-rft96.4%
unpow296.4%
associate-*l*96.4%
unpow296.4%
pow-sqr96.4%
metadata-eval96.4%
Simplified96.4%
if 1.60000000000000016e231 < x Initial program 5.1%
flip3--5.1%
div-inv5.1%
rem-cube-cbrt3.1%
rem-cube-cbrt5.1%
+-commutative5.1%
distribute-rgt-out5.1%
+-commutative5.1%
fma-define5.1%
add-exp-log5.1%
Applied egg-rr5.1%
associate-*r/5.1%
*-rgt-identity5.1%
+-commutative5.1%
associate--l+91.5%
+-inverses91.5%
metadata-eval91.5%
+-commutative91.5%
exp-prod90.8%
Simplified90.8%
add-sqr-sqrt90.8%
unpow-prod-down91.9%
Applied egg-rr91.9%
pow-sqr91.9%
Simplified91.9%
sqr-pow91.9%
pow291.9%
pow-to-exp91.5%
*-commutative91.5%
associate-/l*91.5%
metadata-eval91.5%
*-commutative91.5%
*-un-lft-identity91.5%
pow1/291.5%
log-pow91.5%
rem-log-exp91.5%
metadata-eval91.5%
log1p-undefine91.5%
+-commutative91.5%
log-pow92.1%
add-exp-log91.2%
pow291.2%
unpow1/392.7%
Applied egg-rr98.4%
pow298.4%
pow1/391.2%
pow-pow91.2%
metadata-eval91.2%
Applied egg-rr91.2%
Final simplification95.1%
(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 6.6%
flip3--6.5%
div-inv6.5%
rem-cube-cbrt6.1%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
Applied egg-rr8.3%
associate-*r/8.3%
*-rgt-identity8.3%
+-commutative8.3%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
add-sqr-sqrt92.2%
unpow-prod-down93.6%
Applied egg-rr93.6%
pow-sqr93.6%
Simplified93.6%
sqr-pow93.6%
pow293.6%
pow-to-exp93.0%
*-commutative93.0%
associate-/l*93.0%
metadata-eval93.0%
*-commutative93.0%
*-un-lft-identity93.0%
pow1/293.0%
log-pow93.0%
rem-log-exp93.0%
metadata-eval93.0%
log1p-undefine93.0%
+-commutative93.0%
log-pow93.4%
add-exp-log92.8%
pow292.8%
unpow1/394.3%
Applied egg-rr98.4%
pow298.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(if (<= x 1.32e+154)
(+
(* -0.1111111111111111 (cbrt (/ 1.0 (pow x 5.0))))
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
(if (<= x 1.6e+231)
(pow
(/
(sqrt
(fma
0.3333333333333333
(pow x 1.3333333333333333)
(* (cbrt x) -0.1111111111111111)))
x)
2.0)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0)))))
double code(double x) {
double tmp;
if (x <= 1.32e+154) {
tmp = (-0.1111111111111111 * cbrt((1.0 / pow(x, 5.0)))) + (0.3333333333333333 * cbrt((1.0 / pow(x, 2.0))));
} else if (x <= 1.6e+231) {
tmp = pow((sqrt(fma(0.3333333333333333, pow(x, 1.3333333333333333), (cbrt(x) * -0.1111111111111111))) / x), 2.0);
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.32e+154) tmp = Float64(Float64(-0.1111111111111111 * cbrt(Float64(1.0 / (x ^ 5.0)))) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0))))); elseif (x <= 1.6e+231) tmp = Float64(sqrt(fma(0.3333333333333333, (x ^ 1.3333333333333333), Float64(cbrt(x) * -0.1111111111111111))) / x) ^ 2.0; else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.32e+154], N[(N[(-0.1111111111111111 * N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+231], N[Power[N[(N[Sqrt[N[(0.3333333333333333 * N[Power[x, 1.3333333333333333], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision], 2.0], $MachinePrecision], 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] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;-0.1111111111111111 \cdot \sqrt[3]{\frac{1}{{x}^{5}}} + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+231}:\\
\;\;\;\;{\left(\frac{\sqrt{\mathsf{fma}\left(0.3333333333333333, {x}^{1.3333333333333333}, \sqrt[3]{x} \cdot -0.1111111111111111\right)}}{x}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.31999999999999998e154Initial program 8.4%
Taylor expanded in x around inf 39.9%
+-commutative39.9%
fma-define40.0%
Simplified40.0%
Taylor expanded in x around inf 97.3%
if 1.31999999999999998e154 < x < 1.60000000000000016e231Initial program 4.3%
Taylor expanded in x around inf 0.0%
+-commutative0.0%
fma-define0.0%
Simplified0.0%
add-sqr-sqrt0.0%
pow20.0%
sqrt-div0.0%
sqrt-pow12.3%
metadata-eval2.3%
pow12.3%
Applied egg-rr2.3%
pow1/32.3%
pow-pow87.9%
metadata-eval87.9%
Applied egg-rr87.9%
if 1.60000000000000016e231 < x Initial program 5.1%
flip3--5.1%
div-inv5.1%
rem-cube-cbrt3.1%
rem-cube-cbrt5.1%
+-commutative5.1%
distribute-rgt-out5.1%
+-commutative5.1%
fma-define5.1%
add-exp-log5.1%
Applied egg-rr5.1%
associate-*r/5.1%
*-rgt-identity5.1%
+-commutative5.1%
associate--l+91.5%
+-inverses91.5%
metadata-eval91.5%
+-commutative91.5%
exp-prod90.8%
Simplified90.8%
Taylor expanded in x around 0 20.0%
Final simplification74.7%
(FPCore (x)
:precision binary64
(if (<= x 5.5e+161)
(*
(fma
(cbrt x)
-0.1111111111111111
(* 0.3333333333333333 (pow (cbrt x) 4.0)))
(pow x -2.0))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 5.5e+161) {
tmp = fma(cbrt(x), -0.1111111111111111, (0.3333333333333333 * pow(cbrt(x), 4.0))) * pow(x, -2.0);
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 5.5e+161) tmp = Float64(fma(cbrt(x), -0.1111111111111111, Float64(0.3333333333333333 * (cbrt(x) ^ 4.0))) * (x ^ -2.0)); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 5.5e+161], N[(N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111 + N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision], 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] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{x}, -0.1111111111111111, 0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{4}\right) \cdot {x}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 5.5000000000000005e161Initial program 8.1%
Taylor expanded in x around inf 37.6%
+-commutative37.6%
fma-define37.6%
Simplified37.6%
*-un-lft-identity37.6%
div-inv37.5%
pow-flip37.7%
metadata-eval37.7%
Applied egg-rr37.7%
*-lft-identity37.7%
Simplified94.1%
if 5.5000000000000005e161 < 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.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.8%
Simplified90.8%
Taylor expanded in x around 0 20.0%
Final simplification58.8%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (pow (+ 1.0 x) 0.6666666666666666))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((1.0 + x), 0.6666666666666666));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(1.0 + x) ^ 0.6666666666666666))) end
code[x_] := 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]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(1 + x\right)}^{0.6666666666666666}\right)}
\end{array}
Initial program 6.6%
flip3--6.5%
div-inv6.5%
rem-cube-cbrt6.1%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
Applied egg-rr8.3%
associate-*r/8.3%
*-rgt-identity8.3%
+-commutative8.3%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
add-sqr-sqrt92.2%
unpow-prod-down93.6%
Applied egg-rr93.6%
pow-sqr93.6%
Simplified93.6%
sqr-pow93.6%
pow293.6%
pow-to-exp93.0%
*-commutative93.0%
associate-/l*93.0%
metadata-eval93.0%
*-commutative93.0%
*-un-lft-identity93.0%
pow1/293.0%
log-pow93.0%
rem-log-exp93.0%
metadata-eval93.0%
log1p-undefine93.0%
+-commutative93.0%
log-pow93.4%
add-exp-log92.8%
pow292.8%
unpow1/394.3%
Applied egg-rr98.4%
pow298.4%
pow1/392.8%
pow-pow92.9%
metadata-eval92.9%
Applied egg-rr92.9%
Final simplification92.9%
(FPCore (x)
:precision binary64
(if (<= x 1.32e+154)
(+
(* -0.1111111111111111 (cbrt (/ 1.0 (pow x 5.0))))
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.32e+154) {
tmp = (-0.1111111111111111 * cbrt((1.0 / pow(x, 5.0)))) + (0.3333333333333333 * cbrt((1.0 / pow(x, 2.0))));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.32e+154) tmp = Float64(Float64(-0.1111111111111111 * cbrt(Float64(1.0 / (x ^ 5.0)))) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0))))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.32e+154], N[(N[(-0.1111111111111111 * N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;-0.1111111111111111 \cdot \sqrt[3]{\frac{1}{{x}^{5}}} + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.31999999999999998e154Initial program 8.4%
Taylor expanded in x around inf 39.9%
+-commutative39.9%
fma-define40.0%
Simplified40.0%
Taylor expanded in x around inf 97.3%
if 1.31999999999999998e154 < 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.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 20.0%
Final simplification58.0%
(FPCore (x) :precision binary64 (if (<= x 1.32e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.32e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.32e+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(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.32e+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[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.32 \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]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.31999999999999998e154Initial program 8.4%
Taylor expanded in x around inf 95.6%
if 1.31999999999999998e154 < 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.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 20.0%
Final simplification57.2%
(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.6%
Taylor expanded in x around inf 49.5%
Final simplification49.5%
(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 6.6%
Final simplification6.6%
(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.6%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.2%
fabs-neg5.2%
unpow1/35.2%
metadata-eval5.2%
pow-sqr5.2%
fabs-sqr5.2%
pow-sqr5.2%
metadata-eval5.2%
unpow1/35.2%
Simplified5.2%
Final simplification5.2%
(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 2024115
(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)))