
(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 (+ 1.0 x))) (t_1 (pow t_0 2.0)))
(/
1.0
(fma
(cbrt x)
(* (+ x (+ 1.0 x)) (/ 1.0 (+ t_1 (* (cbrt x) (- (cbrt x) t_0)))))
t_1))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = pow(t_0, 2.0);
return 1.0 / fma(cbrt(x), ((x + (1.0 + x)) * (1.0 / (t_1 + (cbrt(x) * (cbrt(x) - t_0))))), t_1);
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = t_0 ^ 2.0 return Float64(1.0 / fma(cbrt(x), Float64(Float64(x + Float64(1.0 + x)) * Float64(1.0 / Float64(t_1 + Float64(cbrt(x) * Float64(cbrt(x) - t_0))))), t_1)) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[(x + N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := {t\_0}^{2}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \left(x + \left(1 + x\right)\right) \cdot \frac{1}{t\_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - t\_0\right)}, t\_1\right)}
\end{array}
\end{array}
Initial program 7.0%
flip3--7.3%
div-inv7.3%
rem-cube-cbrt6.2%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
+-commutative8.6%
associate--l+93.1%
+-inverses93.1%
metadata-eval93.1%
+-commutative93.1%
exp-prod92.0%
Simplified92.0%
add-sqr-sqrt92.0%
unpow-prod-down93.9%
Applied egg-rr93.9%
pow293.9%
sqrt-pow292.0%
sqrt-pow192.0%
pow-exp93.1%
*-commutative93.1%
log1p-undefine93.1%
+-commutative93.1%
pow-to-exp92.9%
sqrt-pow192.9%
+-commutative92.9%
metadata-eval92.9%
pow1/398.6%
Applied egg-rr98.6%
flip3-+98.5%
div-inv98.5%
+-commutative98.5%
rem-cube-cbrt99.0%
rem-cube-cbrt99.5%
+-commutative99.5%
+-commutative99.5%
+-commutative99.5%
+-commutative99.5%
pow299.5%
+-commutative99.5%
Applied egg-rr99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (pow t_0 2.0)))
(/
1.0
(fma
(cbrt x)
(/ (+ x (+ 1.0 x)) (+ t_1 (* (cbrt x) (- (cbrt x) t_0))))
t_1))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = pow(t_0, 2.0);
return 1.0 / fma(cbrt(x), ((x + (1.0 + x)) / (t_1 + (cbrt(x) * (cbrt(x) - t_0)))), t_1);
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = t_0 ^ 2.0 return Float64(1.0 / fma(cbrt(x), Float64(Float64(x + Float64(1.0 + x)) / Float64(t_1 + Float64(cbrt(x) * Float64(cbrt(x) - t_0)))), t_1)) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[(x + N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := {t\_0}^{2}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \frac{x + \left(1 + x\right)}{t\_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - t\_0\right)}, t\_1\right)}
\end{array}
\end{array}
Initial program 7.0%
flip3--7.3%
div-inv7.3%
rem-cube-cbrt6.2%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
+-commutative8.6%
associate--l+93.1%
+-inverses93.1%
metadata-eval93.1%
+-commutative93.1%
exp-prod92.0%
Simplified92.0%
add-sqr-sqrt92.0%
unpow-prod-down93.9%
Applied egg-rr93.9%
pow293.9%
sqrt-pow292.0%
sqrt-pow192.0%
pow-exp93.1%
*-commutative93.1%
log1p-undefine93.1%
+-commutative93.1%
pow-to-exp92.9%
sqrt-pow192.9%
+-commutative92.9%
metadata-eval92.9%
pow1/398.6%
Applied egg-rr98.6%
flip3-+98.5%
+-commutative98.5%
rem-cube-cbrt99.1%
rem-cube-cbrt99.5%
+-commutative99.5%
+-commutative99.5%
+-commutative99.5%
+-commutative99.5%
pow299.5%
+-commutative99.5%
+-commutative99.5%
distribute-rgt-out--99.5%
+-commutative99.5%
Applied egg-rr99.5%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {t\_0}^{2}\right)}
\end{array}
\end{array}
Initial program 7.0%
flip3--7.3%
div-inv7.3%
rem-cube-cbrt6.2%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
+-commutative8.6%
associate--l+93.1%
+-inverses93.1%
metadata-eval93.1%
+-commutative93.1%
exp-prod92.0%
Simplified92.0%
add-sqr-sqrt92.0%
unpow-prod-down93.9%
Applied egg-rr93.9%
pow293.9%
sqrt-pow292.0%
sqrt-pow192.0%
pow-exp93.1%
*-commutative93.1%
log1p-undefine93.1%
+-commutative93.1%
pow-to-exp92.9%
sqrt-pow192.9%
+-commutative92.9%
metadata-eval92.9%
pow1/398.6%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (x)
:precision binary64
(if (<= x 1.4e+154)
(/
1.0
(+
(+ (cbrt (pow (+ 1.0 x) 2.0)) (cbrt (pow x 2.0)))
(cbrt (* x (+ 1.0 x)))))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (pow (cbrt (+ 1.0 x)) 2.0)))))
double code(double x) {
double tmp;
if (x <= 1.4e+154) {
tmp = 1.0 / ((cbrt(pow((1.0 + x), 2.0)) + cbrt(pow(x, 2.0))) + cbrt((x * (1.0 + x))));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(cbrt((1.0 + x)), 2.0));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.4e+154) tmp = Float64(1.0 / Float64(Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + cbrt((x ^ 2.0))) + cbrt(Float64(x * Float64(1.0 + x))))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (cbrt(Float64(1.0 + x)) ^ 2.0))); end return tmp end
code[x_] := If[LessEqual[x, 1.4e+154], N[(1.0 / N[(N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{{x}^{2}}\right) + \sqrt[3]{x \cdot \left(1 + x\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}\\
\end{array}
\end{array}
if x < 1.4e154Initial program 9.9%
flip3--10.5%
div-inv10.5%
rem-cube-cbrt10.1%
rem-cube-cbrt13.6%
+-commutative13.6%
distribute-rgt-out13.6%
+-commutative13.6%
fma-define13.6%
add-exp-log13.6%
Applied egg-rr13.5%
associate-*r/13.5%
*-rgt-identity13.5%
+-commutative13.5%
associate--l+94.7%
+-inverses94.7%
metadata-eval94.7%
+-commutative94.7%
exp-prod93.6%
Simplified93.6%
add-sqr-sqrt93.6%
unpow-prod-down95.2%
Applied egg-rr95.2%
pow295.2%
sqrt-pow293.6%
sqrt-pow193.6%
pow-exp94.7%
*-commutative94.7%
log1p-undefine94.7%
+-commutative94.7%
pow-to-exp94.4%
sqrt-pow194.4%
+-commutative94.4%
metadata-eval94.4%
pow1/398.5%
Applied egg-rr98.5%
fma-undefine98.5%
+-commutative98.5%
+-commutative98.5%
distribute-rgt-in98.5%
associate-+r+98.5%
unpow298.5%
+-commutative98.5%
+-commutative98.5%
cbrt-unprod98.7%
pow298.7%
+-commutative98.7%
cbrt-unprod99.0%
pow299.0%
+-commutative99.0%
cbrt-unprod99.0%
Applied egg-rr99.0%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod90.7%
Simplified90.7%
add-sqr-sqrt90.7%
unpow-prod-down92.9%
Applied egg-rr92.9%
pow292.9%
sqrt-pow290.7%
sqrt-pow190.7%
pow-exp91.9%
*-commutative91.9%
log1p-undefine91.9%
+-commutative91.9%
pow-to-exp91.6%
sqrt-pow191.6%
+-commutative91.6%
metadata-eval91.6%
pow1/398.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 4e+151)
(/ 1.0 (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) (+ (cbrt x) t_0))))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (pow t_0 2.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 4e+151) {
tmp = 1.0 / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(t_0, 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 4e+151) tmp = Float64(1.0 / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (t_0 ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 4e+151], N[(1.0 / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 4 \cdot 10^{+151}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {t\_0}^{2}\right)}\\
\end{array}
\end{array}
if x < 4.00000000000000007e151Initial program 10.1%
flip3--10.7%
div-inv10.7%
rem-cube-cbrt10.3%
rem-cube-cbrt13.9%
+-commutative13.9%
distribute-rgt-out13.9%
+-commutative13.9%
fma-define13.9%
add-exp-log13.9%
Applied egg-rr13.8%
associate-*r/13.8%
*-rgt-identity13.8%
+-commutative13.8%
associate--l+94.7%
+-inverses94.7%
metadata-eval94.7%
+-commutative94.7%
exp-prod93.7%
Simplified93.7%
add-sqr-sqrt93.7%
unpow-prod-down95.3%
Applied egg-rr95.3%
pow295.3%
sqrt-pow293.7%
sqrt-pow193.7%
pow-exp94.7%
*-commutative94.7%
log1p-undefine94.7%
+-commutative94.7%
pow-to-exp94.5%
sqrt-pow194.5%
+-commutative94.5%
metadata-eval94.5%
pow1/398.5%
Applied egg-rr98.5%
fma-undefine98.5%
+-commutative98.5%
unpow298.5%
+-commutative98.5%
+-commutative98.5%
cbrt-unprod98.7%
pow298.7%
+-commutative98.7%
Applied egg-rr98.7%
if 4.00000000000000007e151 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.0%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+92.0%
+-inverses92.0%
metadata-eval92.0%
+-commutative92.0%
exp-prod90.8%
Simplified90.8%
add-sqr-sqrt90.8%
unpow-prod-down92.9%
Applied egg-rr92.9%
pow292.9%
sqrt-pow290.8%
sqrt-pow190.8%
pow-exp91.9%
*-commutative91.9%
log1p-undefine91.9%
+-commutative91.9%
pow-to-exp91.6%
sqrt-pow191.6%
+-commutative91.6%
metadata-eval91.6%
pow1/398.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification98.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 6.6e+16)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow (+ 1.0 x) 0.6666666666666666)))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (pow t_0 2.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 6.6e+16) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow((1.0 + x), 0.6666666666666666));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(t_0, 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 6.6e+16) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (t_0 ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 6.6e+16], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 6.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {t\_0}^{2}\right)}\\
\end{array}
\end{array}
if x < 6.6e16Initial program 54.8%
flip3--59.6%
div-inv59.6%
rem-cube-cbrt56.6%
rem-cube-cbrt84.6%
+-commutative84.6%
distribute-rgt-out84.7%
+-commutative84.7%
fma-define84.7%
add-exp-log84.7%
Applied egg-rr83.9%
associate-*r/83.9%
*-rgt-identity83.9%
+-commutative83.9%
associate--l+97.8%
+-inverses97.8%
metadata-eval97.8%
+-commutative97.8%
exp-prod97.1%
Simplified97.1%
add-sqr-sqrt97.1%
unpow-prod-down98.0%
Applied egg-rr98.0%
pow-prod-down97.1%
add-sqr-sqrt97.1%
pow-exp97.8%
*-commutative97.8%
exp-prod97.7%
log1p-undefine97.7%
add-exp-log98.0%
Applied egg-rr98.0%
if 6.6e16 < x Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.3%
rem-cube-cbrt4.3%
+-commutative4.3%
distribute-rgt-out4.3%
+-commutative4.3%
fma-define4.3%
add-exp-log4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod91.7%
Simplified91.7%
add-sqr-sqrt91.7%
unpow-prod-down93.7%
Applied egg-rr93.7%
pow293.7%
sqrt-pow291.7%
sqrt-pow191.7%
pow-exp92.9%
*-commutative92.9%
log1p-undefine92.9%
+-commutative92.9%
pow-to-exp92.6%
sqrt-pow192.6%
+-commutative92.6%
metadata-eval92.6%
pow1/398.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification98.5%
(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) 2.0) (exp (* 0.6666666666666666 (log1p 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 / fma(cbrt(x), (cbrt(x) * 2.0), exp((0.6666666666666666 * log1p(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 / fma(cbrt(x), Float64(cbrt(x) * 2.0), exp(Float64(0.6666666666666666 * log1p(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[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $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}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.9%
Taylor expanded in x around inf 94.3%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod90.7%
Simplified90.7%
add-exp-log91.0%
log-pow91.9%
rem-log-exp91.9%
Applied egg-rr91.9%
Taylor expanded in x around inf 91.9%
*-commutative98.6%
Simplified91.9%
Final simplification93.0%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (pow (cbrt (+ 1.0 x)) 2.0))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
Initial program 7.0%
flip3--7.3%
div-inv7.3%
rem-cube-cbrt6.2%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
+-commutative8.6%
associate--l+93.1%
+-inverses93.1%
metadata-eval93.1%
+-commutative93.1%
exp-prod92.0%
Simplified92.0%
add-sqr-sqrt92.0%
unpow-prod-down93.9%
Applied egg-rr93.9%
pow293.9%
sqrt-pow292.0%
sqrt-pow192.0%
pow-exp93.1%
*-commutative93.1%
log1p-undefine93.1%
+-commutative93.1%
pow-to-exp92.9%
sqrt-pow192.9%
+-commutative92.9%
metadata-eval92.9%
pow1/398.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 96.7%
*-commutative96.7%
Simplified96.7%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (pow (* (cbrt (/ 1.0 x)) (sqrt 0.5)) 2.0)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = pow((cbrt((1.0 / x)) * sqrt(0.5)), 2.0);
}
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 = Math.pow((Math.cbrt((1.0 / x)) * Math.sqrt(0.5)), 2.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(cbrt(Float64(1.0 / x)) * sqrt(0.5)) ^ 2.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[Power[N[(N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], 2.0], $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}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{1}{x}} \cdot \sqrt{0.5}\right)}^{2}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.9%
Taylor expanded in x around inf 94.3%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod90.7%
Simplified90.7%
add-sqr-sqrt90.7%
pow290.7%
inv-pow90.7%
sqrt-pow190.7%
+-commutative90.7%
metadata-eval90.7%
Applied egg-rr90.7%
Taylor expanded in x around inf 20.0%
(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 9.9%
Taylor expanded in x around inf 94.3%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod90.7%
Simplified90.7%
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 7.0%
Taylor expanded in x around inf 44.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 7.0%
Final simplification7.0%
(FPCore (x) :precision binary64 (cbrt x))
double code(double x) {
return cbrt(x);
}
public static double code(double x) {
return Math.cbrt(x);
}
function code(x) return cbrt(x) end
code[x_] := N[Power[x, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x}
\end{array}
Initial program 7.0%
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%
Taylor expanded in x around inf 5.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 2024130
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (cbrt (+ x 1)) (cbrt (+ x 1))) (* (cbrt x) (cbrt (+ x 1))) (* (cbrt x) (cbrt x)))))
(- (cbrt (+ x 1.0)) (cbrt x)))