
(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 (pow (+ 1.0 x) 0.25))))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ 1.0 x)))
(* (* t_0 t_0) (sqrt (+ 1.0 x)))))))
double code(double x) {
double t_0 = cbrt(pow((1.0 + x), 0.25));
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), ((t_0 * t_0) * sqrt((1.0 + x))));
}
function code(x) t_0 = cbrt((Float64(1.0 + x) ^ 0.25)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), Float64(Float64(t_0 * t_0) * sqrt(Float64(1.0 + x))))) end
code[x_] := Block[{t$95$0 = N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 0.25], $MachinePrecision], 1/3], $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[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{{\left(1 + x\right)}^{0.25}}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, \left(t\_0 \cdot t\_0\right) \cdot \sqrt{1 + x}\right)}
\end{array}
\end{array}
Initial program 6.9%
flip3--7.1%
div-inv7.1%
rem-cube-cbrt6.3%
rem-cube-cbrt9.3%
+-commutative9.3%
distribute-rgt-out9.3%
+-commutative9.3%
fma-define9.3%
add-exp-log9.3%
Applied egg-rr9.3%
associate-*r/9.3%
*-rgt-identity9.3%
+-commutative9.3%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.4%
Simplified92.4%
Applied egg-rr95.9%
*-commutative95.9%
+-commutative95.9%
hypot-undefine95.9%
metadata-eval95.9%
rem-square-sqrt95.9%
Simplified95.9%
add-sqr-sqrt95.9%
unpow-prod-down95.9%
add-sqr-sqrt95.9%
hypot-1-def95.9%
add-sqr-sqrt95.8%
hypot-1-def95.8%
Applied egg-rr95.8%
pow-sqr95.9%
metadata-eval95.9%
unpow1/398.7%
hypot-undefine98.7%
metadata-eval98.7%
rem-square-sqrt98.7%
+-commutative98.7%
Simplified98.7%
pow1/395.9%
+-commutative95.9%
add-sqr-sqrt95.8%
unpow-prod-down95.8%
pow1/295.8%
+-commutative95.8%
sqrt-pow195.8%
metadata-eval95.8%
pow1/295.8%
+-commutative95.8%
sqrt-pow195.8%
metadata-eval95.8%
Applied egg-rr95.8%
unpow1/397.0%
+-commutative97.0%
unpow1/398.8%
+-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 2e-11)
(/ 1.0 (* (cbrt x) (+ (cbrt x) t_1)))
(/ 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 ((t_0 - cbrt(x)) <= 2e-11) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + t_1));
} 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 (Float64(t_0 - cbrt(x)) <= 2e-11) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + t_1))); 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[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 2e-11], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$1), $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}\;t\_0 - \sqrt[3]{x} \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_1\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 (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 1.99999999999999988e-11Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.6%
rem-cube-cbrt4.5%
+-commutative4.5%
distribute-rgt-out4.5%
+-commutative4.5%
fma-define4.5%
add-exp-log4.6%
Applied egg-rr4.5%
associate-*r/4.5%
*-rgt-identity4.5%
+-commutative4.5%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 53.1%
unpow253.1%
rem-cube-cbrt53.1%
rem-cube-cbrt53.0%
cube-prod52.9%
unpow252.9%
rem-cbrt-cube98.4%
Simplified98.4%
fma-undefine98.4%
unpow298.4%
distribute-lft-out98.4%
+-commutative98.4%
+-commutative98.4%
Applied egg-rr98.4%
if 1.99999999999999988e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 56.5%
flip3--61.7%
div-inv61.7%
rem-cube-cbrt56.4%
rem-cube-cbrt98.5%
+-commutative98.5%
distribute-rgt-out98.5%
+-commutative98.5%
fma-define98.5%
add-exp-log97.6%
Applied egg-rr97.5%
associate-*r/97.5%
*-rgt-identity97.5%
+-commutative97.5%
associate--l+97.5%
+-inverses97.5%
metadata-eval97.5%
+-commutative97.5%
exp-prod97.4%
Simplified97.4%
Applied egg-rr99.1%
*-commutative99.1%
+-commutative99.1%
hypot-undefine98.9%
metadata-eval98.9%
rem-square-sqrt99.1%
Simplified99.1%
pow1/299.1%
pow-prod-up98.1%
+-commutative98.1%
metadata-eval98.1%
Applied egg-rr98.1%
Final simplification98.4%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (* t_0 (cbrt t_0))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), (t_0 * cbrt(t_0)));
}
function code(x) t_0 = sqrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), Float64(t_0 * cbrt(t_0)))) end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $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] + N[(t$95$0 * N[Power[t$95$0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, t\_0 \cdot \sqrt[3]{t\_0}\right)}
\end{array}
\end{array}
Initial program 6.9%
flip3--7.1%
div-inv7.1%
rem-cube-cbrt6.3%
rem-cube-cbrt9.3%
+-commutative9.3%
distribute-rgt-out9.3%
+-commutative9.3%
fma-define9.3%
add-exp-log9.3%
Applied egg-rr9.3%
associate-*r/9.3%
*-rgt-identity9.3%
+-commutative9.3%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.4%
Simplified92.4%
Applied egg-rr95.9%
*-commutative95.9%
+-commutative95.9%
hypot-undefine95.9%
metadata-eval95.9%
rem-square-sqrt95.9%
Simplified95.9%
add-sqr-sqrt95.9%
unpow-prod-down95.9%
add-sqr-sqrt95.9%
hypot-1-def95.9%
add-sqr-sqrt95.8%
hypot-1-def95.8%
Applied egg-rr95.8%
pow-sqr95.9%
metadata-eval95.9%
unpow1/398.7%
hypot-undefine98.7%
metadata-eval98.7%
rem-square-sqrt98.7%
+-commutative98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x)
:precision binary64
(if (<= x 5e+151)
(/
1.0
(fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow (cbrt x) 2.0)))))
double code(double x) {
double tmp;
if (x <= 5e+151) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(cbrt(x), 2.0));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 5e+151) 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 / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (cbrt(x) ^ 2.0))); end return tmp end
code[x_] := If[LessEqual[x, 5e+151], 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[(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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+151}:\\
\;\;\;\;\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}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\end{array}
\end{array}
if x < 5.0000000000000002e151Initial program 8.7%
flip3--9.2%
div-inv9.2%
rem-cube-cbrt9.0%
rem-cube-cbrt13.3%
+-commutative13.3%
distribute-rgt-out13.3%
+-commutative13.3%
fma-define13.3%
add-exp-log13.2%
Applied egg-rr13.2%
associate-*r/13.2%
*-rgt-identity13.2%
+-commutative13.2%
associate--l+94.7%
+-inverses94.7%
metadata-eval94.7%
+-commutative94.7%
exp-prod93.9%
Simplified93.9%
pow-exp94.7%
*-commutative94.7%
log1p-undefine94.8%
+-commutative94.8%
exp-to-pow94.5%
metadata-eval94.5%
pow-sqr94.5%
pow1/395.9%
pow1/398.4%
cbrt-unprod98.8%
pow298.8%
Applied egg-rr98.8%
if 5.0000000000000002e151 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.2%
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.6%
+-inverses91.6%
metadata-eval91.6%
+-commutative91.6%
exp-prod90.7%
Simplified90.7%
Taylor expanded in x around inf 5.6%
unpow25.6%
rem-cube-cbrt5.6%
rem-cube-cbrt5.6%
cube-prod5.6%
unpow25.6%
rem-cbrt-cube98.4%
Simplified98.4%
Taylor expanded in x around inf 98.4%
Final simplification98.6%
(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.9%
flip3--7.1%
div-inv7.1%
rem-cube-cbrt6.3%
rem-cube-cbrt9.3%
+-commutative9.3%
distribute-rgt-out9.3%
+-commutative9.3%
fma-define9.3%
add-exp-log9.3%
Applied egg-rr9.3%
associate-*r/9.3%
*-rgt-identity9.3%
+-commutative9.3%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.4%
Simplified92.4%
Applied egg-rr95.9%
*-commutative95.9%
+-commutative95.9%
hypot-undefine95.9%
metadata-eval95.9%
rem-square-sqrt95.9%
Simplified95.9%
pow1/295.9%
pow-prod-up93.1%
+-commutative93.1%
metadata-eval93.1%
Applied egg-rr93.1%
metadata-eval93.1%
pow-sqr93.1%
unpow1/394.5%
unpow1/398.4%
unpow298.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= x 5e+14)
(/ (- (+ 1.0 x) x) (+ (pow t_0 2.0) (* (cbrt x) t_1)))
(/ 1.0 (* (cbrt x) (+ (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 (x <= 5e+14) {
tmp = ((1.0 + x) - x) / (pow(t_0, 2.0) + (cbrt(x) * t_1));
} else {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + t_1));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = Math.cbrt(x) + t_0;
double tmp;
if (x <= 5e+14) {
tmp = ((1.0 + x) - x) / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * t_1));
} else {
tmp = 1.0 / (Math.cbrt(x) * (Math.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 (x <= 5e+14) tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * t_1))); else tmp = Float64(1.0 / Float64(cbrt(x) * 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[x, 5e+14], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 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}\;x \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{{t\_0}^{2} + \sqrt[3]{x} \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_1\right)}\\
\end{array}
\end{array}
if x < 5e14Initial program 56.5%
pow1/353.6%
pow-to-exp53.6%
+-commutative53.6%
log1p-define53.3%
Applied egg-rr53.3%
Applied egg-rr98.5%
if 5e14 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.6%
rem-cube-cbrt4.5%
+-commutative4.5%
distribute-rgt-out4.5%
+-commutative4.5%
fma-define4.5%
add-exp-log4.6%
Applied egg-rr4.5%
associate-*r/4.5%
*-rgt-identity4.5%
+-commutative4.5%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 53.1%
unpow253.1%
rem-cube-cbrt53.1%
rem-cube-cbrt53.0%
cube-prod52.9%
unpow252.9%
rem-cbrt-cube98.4%
Simplified98.4%
fma-undefine98.4%
unpow298.4%
distribute-lft-out98.4%
+-commutative98.4%
+-commutative98.4%
Applied egg-rr98.4%
Final simplification98.4%
(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 (+ 1.0 x))) 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((1.0 + x))), 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(1.0 + x))), 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[(1.0 + x), $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]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 8.7%
Taylor expanded in x around inf 95.3%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.2%
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.6%
+-inverses91.6%
metadata-eval91.6%
+-commutative91.6%
exp-prod90.7%
Simplified90.7%
Taylor expanded in x around 0 20.0%
Final simplification60.6%
(FPCore (x) :precision binary64 (/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))))))
double code(double x) {
return 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + cbrt((1.0 + x)))));
}
public static double code(double x) {
return 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
}
function code(x) return Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))) 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[(1.0 + x), $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]{1 + x}\right)\right)}
\end{array}
Initial program 6.9%
flip3--7.1%
div-inv7.1%
rem-cube-cbrt6.3%
rem-cube-cbrt9.3%
+-commutative9.3%
distribute-rgt-out9.3%
+-commutative9.3%
fma-define9.3%
add-exp-log9.3%
Applied egg-rr9.3%
associate-*r/9.3%
*-rgt-identity9.3%
+-commutative9.3%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.4%
Simplified92.4%
Taylor expanded in x around inf 53.6%
unpow253.6%
rem-cube-cbrt53.6%
rem-cube-cbrt53.5%
cube-prod53.5%
unpow253.5%
rem-cbrt-cube96.6%
Simplified96.6%
fma-undefine96.6%
unpow296.6%
distribute-lft-out96.6%
+-commutative96.6%
+-commutative96.6%
Applied egg-rr96.6%
Final simplification96.6%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (/ 1.0 (+ 1.0 (* (cbrt x) (+ 1.0 (cbrt x)))))))
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 / (1.0 + (cbrt(x) * (1.0 + cbrt(x))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (1.0 + Math.cbrt(x))));
}
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 / Float64(1.0 + Float64(cbrt(x) * Float64(1.0 + cbrt(x))))); 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[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}{1 + \sqrt[3]{x} \cdot \left(1 + \sqrt[3]{x}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 8.7%
Taylor expanded in x around inf 95.3%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.2%
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.6%
+-inverses91.6%
metadata-eval91.6%
+-commutative91.6%
exp-prod90.7%
Simplified90.7%
Applied egg-rr94.4%
*-commutative94.4%
+-commutative94.4%
hypot-undefine94.4%
metadata-eval94.4%
rem-square-sqrt94.4%
Simplified94.4%
pow1/294.4%
pow-prod-up91.4%
+-commutative91.4%
metadata-eval91.4%
Applied egg-rr91.4%
Taylor expanded in x around 0 17.7%
(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 53.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 6.9%
Final simplification6.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.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%
(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 6.9%
pow1/34.5%
pow-to-exp5.3%
+-commutative5.3%
log1p-define5.3%
Applied egg-rr5.3%
*-commutative5.3%
exp-prod5.8%
Applied egg-rr5.8%
Taylor expanded in x around inf 4.1%
(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 2024108
(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)))