
(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 14 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))))
(/
1.0
(fma
(cbrt x)
(+ (* (pow x 0.16666666666666666) (cbrt (sqrt x))) t_0)
(*
(*
(cbrt (pow (+ 1.0 x) 0.16666666666666666))
(cbrt (pow (+ 1.0 x) 0.8333333333333334)))
t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), ((pow(x, 0.16666666666666666) * cbrt(sqrt(x))) + t_0), ((cbrt(pow((1.0 + x), 0.16666666666666666)) * cbrt(pow((1.0 + x), 0.8333333333333334))) * t_0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(Float64((x ^ 0.16666666666666666) * cbrt(sqrt(x))) + t_0), Float64(Float64(cbrt((Float64(1.0 + x) ^ 0.16666666666666666)) * cbrt((Float64(1.0 + x) ^ 0.8333333333333334))) * t_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[(N[Power[x, 0.16666666666666666], $MachinePrecision] * N[Power[N[Sqrt[x], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 0.16666666666666666], $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 0.8333333333333334], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, {x}^{0.16666666666666666} \cdot \sqrt[3]{\sqrt{x}} + t\_0, \left(\sqrt[3]{{\left(1 + x\right)}^{0.16666666666666666}} \cdot \sqrt[3]{{\left(1 + x\right)}^{0.8333333333333334}}\right) \cdot t\_0\right)}
\end{array}
\end{array}
Initial program 6.9%
flip3--7.8%
div-inv7.8%
rem-cube-cbrt7.4%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-def9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.3%
Simplified92.3%
metadata-eval92.3%
prod-exp92.3%
pow-prod-down93.8%
pow293.8%
pow-exp93.3%
log1p-udef93.3%
+-commutative93.3%
log-pow93.7%
add-exp-log93.0%
pow1/398.6%
pow298.6%
Applied egg-rr98.6%
pow1/394.4%
*-rgt-identity94.4%
add-sqr-sqrt94.4%
associate-*l*94.4%
unpow-prod-down94.4%
pow1/294.4%
pow-pow94.4%
metadata-eval94.4%
Applied egg-rr94.4%
unpow1/395.8%
*-rgt-identity95.8%
Simplified95.8%
pow1/393.6%
add-cube-cbrt93.6%
add-sqr-sqrt93.6%
associate-*r*93.6%
unpow-prod-down93.6%
Applied egg-rr94.4%
unpow1/394.8%
*-commutative94.8%
+-commutative94.8%
unpow1/398.8%
+-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (sqrt x))) (t_1 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (* t_0 t_0) (+ (cbrt x) t_1) (pow t_1 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt(x));
double t_1 = cbrt((1.0 + x));
return 1.0 / fma((t_0 * t_0), (cbrt(x) + t_1), pow(t_1, 2.0));
}
function code(x) t_0 = cbrt(sqrt(x)) t_1 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(Float64(t_0 * t_0), Float64(cbrt(x) + t_1), (t_1 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[Sqrt[x], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$1), $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt{x}}\\
t_1 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(t\_0 \cdot t\_0, \sqrt[3]{x} + t\_1, {t\_1}^{2}\right)}
\end{array}
\end{array}
Initial program 6.9%
flip3--7.8%
div-inv7.8%
rem-cube-cbrt7.4%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-def9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.3%
Simplified92.3%
metadata-eval92.3%
prod-exp92.3%
pow-prod-down93.8%
pow293.8%
pow-exp93.3%
log1p-udef93.3%
+-commutative93.3%
log-pow93.7%
add-exp-log93.0%
pow1/398.6%
pow298.6%
Applied egg-rr98.6%
pow1/37.7%
add-sqr-sqrt7.7%
unpow-prod-down7.7%
pow-prod-up7.7%
metadata-eval7.7%
Applied egg-rr93.0%
*-rgt-identity93.0%
metadata-eval93.0%
pow-sqr93.0%
unpow1/394.5%
*-rgt-identity94.5%
unpow1/398.6%
*-rgt-identity98.6%
Simplified98.6%
pow298.6%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))
(+
(pow (+ 1.0 x) 0.3333333333333333)
(- 0.0 (pow x 0.3333333333333333))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
} else {
tmp = pow((1.0 + x), 0.3333333333333333) + (0.0 - pow(x, 0.3333333333333333));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); else tmp = Float64((Float64(1.0 + x) ^ 0.3333333333333333) + Float64(0.0 - (x ^ 0.3333333333333333))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $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] + t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] + N[(0.0 - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(1 + x\right)}^{0.3333333333333333} + \left(0 - {x}^{0.3333333333333333}\right)\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-def5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.0%
Simplified92.0%
Taylor expanded in x around 0 20.0%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 55.7%
pow1/351.1%
Applied egg-rr51.1%
pow1/356.1%
Applied egg-rr56.1%
Final simplification21.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x 2e+153)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (fma (cbrt x) t_0 (pow (cbrt x) 2.0))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= 2e+153) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow(cbrt(x), 2.0));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= 2e+153) 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, (cbrt(x) ^ 2.0))); 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, 2e+153], 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[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+153}:\\
\;\;\;\;\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, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\end{array}
\end{array}
if x < 2e153Initial program 9.3%
flip3--11.3%
div-inv11.3%
rem-cube-cbrt12.0%
rem-cube-cbrt15.4%
+-commutative15.4%
distribute-rgt-out15.4%
+-commutative15.4%
fma-def15.4%
add-exp-log15.3%
Applied egg-rr15.3%
associate-*r/15.3%
*-rgt-identity15.3%
+-commutative15.3%
associate--l+94.5%
+-inverses94.5%
metadata-eval94.5%
+-commutative94.5%
exp-prod93.7%
Simplified93.7%
metadata-eval93.7%
prod-exp93.7%
pow-prod-down95.0%
pow295.0%
pow-exp94.6%
log1p-udef94.6%
+-commutative94.6%
log-pow95.0%
add-exp-log94.5%
pow1/398.5%
pow298.5%
cbrt-unprod98.9%
pow298.9%
Applied egg-rr98.9%
if 2e153 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.2%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-def4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+92.1%
+-inverses92.1%
metadata-eval92.1%
+-commutative92.1%
exp-prod91.1%
Simplified91.1%
add-sqr-sqrt91.1%
sqrt-unprod51.1%
pow-prod-down52.1%
prod-exp52.1%
metadata-eval52.1%
Applied egg-rr52.1%
Taylor expanded in x around inf 4.7%
unpow1/34.7%
Simplified4.7%
expm1-log1p-u4.7%
expm1-udef4.7%
add-cbrt-cube4.7%
pow1/34.7%
sqrt-unprod4.7%
sqrt-prod4.7%
add-cube-cbrt4.7%
sqrt-pow15.3%
metadata-eval5.3%
pow25.3%
pow-prod-down92.4%
pow292.4%
unpow1/393.1%
Applied egg-rr93.1%
expm1-def93.1%
expm1-log1p98.7%
Simplified98.7%
Final simplification98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= x 9.2e+14)
(/ (- (+ 1.0 x) x) (+ (pow t_0 2.0) (* (cbrt x) t_1)))
(/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) + t_0;
double tmp;
if (x <= 9.2e+14) {
tmp = ((1.0 + x) - x) / (pow(t_0, 2.0) + (cbrt(x) * t_1));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (x <= 9.2e+14) tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * t_1))); 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[(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, 9.2e+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] * 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]{1 + x}\\
t_1 := \sqrt[3]{x} + t\_0\\
\mathbf{if}\;x \leq 9.2 \cdot 10^{+14}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{{t\_0}^{2} + \sqrt[3]{x} \cdot t\_1}\\
\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 < 9.2e14Initial program 55.7%
expm1-log1p-u51.8%
Applied egg-rr51.8%
+-commutative51.8%
expm1-log1p-u55.7%
flip3--74.6%
rem-cube-cbrt72.6%
+-commutative72.6%
rem-cube-cbrt98.6%
cbrt-prod98.7%
+-commutative98.7%
+-commutative98.7%
cbrt-unprod98.6%
pow298.6%
+-commutative98.6%
distribute-rgt-out98.6%
+-commutative98.6%
Applied egg-rr98.6%
if 9.2e14 < x Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-def5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.0%
Simplified92.0%
add-sqr-sqrt92.1%
sqrt-unprod69.8%
pow-prod-down70.8%
prod-exp70.8%
metadata-eval70.8%
Applied egg-rr70.8%
Taylor expanded in x around inf 24.6%
unpow1/325.5%
Simplified25.5%
expm1-log1p-u24.8%
expm1-udef24.8%
add-cbrt-cube24.8%
pow1/324.6%
sqrt-unprod24.6%
sqrt-prod24.6%
add-cube-cbrt24.6%
sqrt-pow145.0%
metadata-eval45.0%
pow245.0%
pow-prod-down93.4%
pow293.4%
unpow1/394.0%
Applied egg-rr94.0%
expm1-def94.0%
expm1-log1p98.6%
Simplified98.6%
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.8%
div-inv7.8%
rem-cube-cbrt7.4%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-def9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.3%
Simplified92.3%
metadata-eval92.3%
prod-exp92.3%
pow-prod-down93.8%
pow293.8%
pow-exp93.3%
log1p-udef93.3%
+-commutative93.3%
log-pow93.7%
add-exp-log93.0%
pow1/398.6%
pow298.6%
Applied egg-rr98.6%
pow298.6%
Applied egg-rr98.6%
Final simplification98.6%
(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.9%
flip3--7.8%
div-inv7.8%
rem-cube-cbrt7.4%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-def9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.3%
Simplified92.3%
metadata-eval92.3%
prod-exp92.3%
pow-prod-down93.8%
pow293.8%
pow-exp93.3%
log1p-udef93.3%
+-commutative93.3%
log-pow93.7%
add-exp-log93.0%
pow1/398.6%
pow298.6%
Applied egg-rr98.6%
pow298.6%
pow1/393.0%
+-commutative93.0%
pow-pow93.0%
+-commutative93.0%
metadata-eval93.0%
Applied egg-rr93.0%
Final simplification93.0%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (pow x 0.6666666666666666))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow(x, 0.6666666666666666));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (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[x, 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {x}^{0.6666666666666666}\right)}
\end{array}
Initial program 6.9%
flip3--7.8%
div-inv7.8%
rem-cube-cbrt7.4%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-def9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.3%
Simplified92.3%
add-sqr-sqrt92.3%
sqrt-unprod71.2%
pow-prod-down72.2%
prod-exp72.2%
metadata-eval72.2%
Applied egg-rr72.2%
Taylor expanded in x around inf 26.7%
unpow1/327.5%
Simplified27.5%
add-cbrt-cube27.5%
pow1/326.7%
sqrt-unprod26.7%
sqrt-prod26.7%
add-cube-cbrt26.7%
sqrt-pow145.9%
metadata-eval45.9%
pow245.9%
pow-prod-down91.4%
pow-prod-up91.4%
metadata-eval91.4%
Applied egg-rr91.4%
Final simplification91.4%
(FPCore (x) :precision binary64 (- (cbrt (+ 1.0 x)) (* (pow x 0.25) (pow x 0.08333333333333333))))
double code(double x) {
return cbrt((1.0 + x)) - (pow(x, 0.25) * pow(x, 0.08333333333333333));
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) - (Math.pow(x, 0.25) * Math.pow(x, 0.08333333333333333));
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) - Float64((x ^ 0.25) * (x ^ 0.08333333333333333))) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[(N[Power[x, 0.25], $MachinePrecision] * N[Power[x, 0.08333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} - {x}^{0.25} \cdot {x}^{0.08333333333333333}
\end{array}
Initial program 6.9%
pow1/37.7%
Applied egg-rr7.7%
metadata-eval7.7%
pow-prod-up7.7%
metadata-eval7.7%
sqrt-pow27.7%
pow1/37.9%
sqr-pow7.8%
associate-*r*7.8%
Applied egg-rr7.9%
Final simplification7.9%
(FPCore (x) :precision binary64 (- (cbrt (+ 1.0 x)) (pow (sqrt x) 0.6666666666666666)))
double code(double x) {
return cbrt((1.0 + x)) - pow(sqrt(x), 0.6666666666666666);
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) - Math.pow(Math.sqrt(x), 0.6666666666666666);
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) - (sqrt(x) ^ 0.6666666666666666)) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[N[Sqrt[x], $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} - {\left(\sqrt{x}\right)}^{0.6666666666666666}
\end{array}
Initial program 6.9%
pow1/37.7%
add-sqr-sqrt7.7%
unpow-prod-down7.7%
pow-prod-up7.7%
metadata-eval7.7%
Applied egg-rr7.7%
Final simplification7.7%
(FPCore (x) :precision binary64 (if (<= x 8e+15) (- (cbrt (+ 1.0 x)) (cbrt x)) 1.0))
double code(double x) {
double tmp;
if (x <= 8e+15) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 1.0;
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 8e+15) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 1.0;
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 8e+15) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = 1.0; end return tmp end
code[x_] := If[LessEqual[x, 8e+15], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{+15}:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 8e15Initial program 53.0%
if 8e15 < x Initial program 4.2%
Taylor expanded in x around 0 5.9%
Final simplification8.4%
(FPCore (x) :precision binary64 (+ (cbrt (+ 1.0 x)) (- 0.0 (pow x 0.3333333333333333))))
double code(double x) {
return cbrt((1.0 + x)) + (0.0 - pow(x, 0.3333333333333333));
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) + (0.0 - Math.pow(x, 0.3333333333333333));
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) + Float64(0.0 - (x ^ 0.3333333333333333))) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + N[(0.0 - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} + \left(0 - {x}^{0.3333333333333333}\right)
\end{array}
Initial program 6.9%
pow1/37.7%
Applied egg-rr7.7%
Final simplification7.7%
(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%
Taylor expanded in x around inf 4.2%
Final simplification4.2%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 6.9%
Taylor expanded in x around 0 6.2%
Final simplification6.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 2024031
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:herbie-target
(/ 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)))