
(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 11 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 (cbrt (/ 1.0 (pow x 2.0)))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/
(+
(* -0.1388888888888889 t_1)
(+ (* t_1 0.027777777777777776) (* (cbrt x) 0.3333333333333333)))
x)
(/
(+ 1.0 (- x x))
(+ (* (cbrt x) (+ (cbrt x) t_0)) (cbrt (pow (+ 1.0 x) 2.0)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt((1.0 / pow(x, 2.0)));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = ((-0.1388888888888889 * t_1) + ((t_1 * 0.027777777777777776) + (cbrt(x) * 0.3333333333333333))) / x;
} else {
tmp = (1.0 + (x - x)) / ((cbrt(x) * (cbrt(x) + t_0)) + cbrt(pow((1.0 + x), 2.0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = Math.cbrt((1.0 / Math.pow(x, 2.0)));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = ((-0.1388888888888889 * t_1) + ((t_1 * 0.027777777777777776) + (Math.cbrt(x) * 0.3333333333333333))) / x;
} else {
tmp = (1.0 + (x - x)) / ((Math.cbrt(x) * (Math.cbrt(x) + t_0)) + Math.cbrt(Math.pow((1.0 + x), 2.0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = cbrt(Float64(1.0 / (x ^ 2.0))) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(Float64(Float64(-0.1388888888888889 * t_1) + Float64(Float64(t_1 * 0.027777777777777776) + Float64(cbrt(x) * 0.3333333333333333))) / x); else tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(Float64(cbrt(x) * Float64(cbrt(x) + t_0)) + cbrt((Float64(1.0 + 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[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(-0.1388888888888889 * t$95$1), $MachinePrecision] + N[(N[(t$95$1 * 0.027777777777777776), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{-0.1388888888888889 \cdot t\_1 + \left(t\_1 \cdot 0.027777777777777776 + \sqrt[3]{x} \cdot 0.3333333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right) + \sqrt[3]{{\left(1 + x\right)}^{2}}}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 0.0Initial program 4.2%
add-sqr-sqrt4.2%
add-sqr-sqrt4.2%
difference-of-squares4.2%
pow1/34.2%
sqrt-pow14.2%
metadata-eval4.2%
pow1/34.2%
sqrt-pow14.2%
metadata-eval4.2%
pow1/31.8%
sqrt-pow11.8%
metadata-eval1.8%
pow1/34.3%
sqrt-pow14.2%
metadata-eval4.2%
Applied egg-rr4.2%
Taylor expanded in x around inf 99.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 62.1%
flip3--69.2%
div-inv69.2%
rem-cube-cbrt66.1%
rem-cube-cbrt99.1%
+-commutative99.1%
distribute-rgt-out98.8%
+-commutative98.8%
fma-define98.6%
add-exp-log98.5%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
+-commutative98.1%
associate--l+98.1%
+-commutative98.1%
+-commutative98.1%
Simplified98.1%
*-commutative98.1%
log1p-undefine98.1%
exp-to-pow98.0%
metadata-eval98.0%
metadata-eval98.0%
pow-sqr98.0%
+-commutative98.0%
metadata-eval98.0%
pow1/398.9%
+-commutative98.9%
metadata-eval98.9%
pow1/398.6%
pow298.6%
+-commutative98.6%
Applied egg-rr98.6%
pow1/398.0%
metadata-eval98.0%
add-sqr-sqrt98.1%
unpow-prod-down98.1%
metadata-eval98.1%
metadata-eval98.1%
Applied egg-rr98.1%
unpow1/398.7%
unpow1/398.5%
Simplified98.5%
fma-undefine98.6%
cbrt-unprod98.6%
add-sqr-sqrt98.8%
pow298.8%
cbrt-unprod99.2%
pow299.2%
Applied egg-rr99.2%
Final simplification99.0%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (sqrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (pow (* t_0 t_0) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((t_0 * t_0), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(t_0 * t_0) ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[Sqrt[N[(1.0 + x), $MachinePrecision]], $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[Power[N[(t$95$0 * t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt{1 + x}}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(t\_0 \cdot t\_0\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 9.0%
flip3--9.6%
div-inv9.6%
rem-cube-cbrt8.7%
rem-cube-cbrt12.4%
+-commutative12.4%
distribute-rgt-out12.4%
+-commutative12.4%
fma-define12.4%
add-exp-log12.3%
Applied egg-rr12.3%
associate-*r/12.3%
*-rgt-identity12.3%
+-commutative12.3%
associate--l+93.4%
+-commutative93.4%
+-commutative93.4%
Simplified93.4%
*-commutative93.4%
log1p-undefine93.4%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
+-commutative93.1%
metadata-eval93.1%
pow1/394.6%
+-commutative94.6%
metadata-eval94.6%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
pow1/393.1%
metadata-eval93.1%
add-sqr-sqrt93.1%
unpow-prod-down93.1%
metadata-eval93.1%
metadata-eval93.1%
Applied egg-rr93.1%
unpow1/394.6%
unpow1/398.4%
Simplified98.4%
Taylor expanded in x around 0 98.4%
(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 9.0%
flip3--9.6%
div-inv9.6%
rem-cube-cbrt8.7%
rem-cube-cbrt12.4%
+-commutative12.4%
distribute-rgt-out12.4%
+-commutative12.4%
fma-define12.4%
add-exp-log12.3%
Applied egg-rr12.3%
associate-*r/12.3%
*-rgt-identity12.3%
+-commutative12.3%
associate--l+93.4%
+-commutative93.4%
+-commutative93.4%
Simplified93.4%
*-commutative93.4%
log1p-undefine93.4%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
+-commutative93.1%
metadata-eval93.1%
pow1/394.6%
+-commutative94.6%
metadata-eval94.6%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 98.4%
(FPCore (x)
:precision binary64
(if (<= x 1.4e+154)
(/
(+ 1.0 (- x x))
(+ (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))) (cbrt (pow (+ 1.0 x) 2.0))))
(* (/ 1.0 (cbrt x)) (/ (pow (sqrt 0.3333333333333333) 2.0) (cbrt x)))))
double code(double x) {
double tmp;
if (x <= 1.4e+154) {
tmp = (1.0 + (x - x)) / ((cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))) + cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = (1.0 / cbrt(x)) * (pow(sqrt(0.3333333333333333), 2.0) / cbrt(x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.4e+154) {
tmp = (1.0 + (x - x)) / ((Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)))) + Math.cbrt(Math.pow((1.0 + x), 2.0)));
} else {
tmp = (1.0 / Math.cbrt(x)) * (Math.pow(Math.sqrt(0.3333333333333333), 2.0) / Math.cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.4e+154) tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))) + cbrt((Float64(1.0 + x) ^ 2.0)))); else tmp = Float64(Float64(1.0 / cbrt(x)) * Float64((sqrt(0.3333333333333333) ^ 2.0) / cbrt(x))); end return tmp end
code[x_] := If[LessEqual[x, 1.4e+154], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(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] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Sqrt[0.3333333333333333], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right) + \sqrt[3]{{\left(1 + x\right)}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x}} \cdot \frac{{\left(\sqrt{0.3333333333333333}\right)}^{2}}{\sqrt[3]{x}}\\
\end{array}
\end{array}
if x < 1.4e154Initial program 13.2%
flip3--14.4%
div-inv14.4%
rem-cube-cbrt14.3%
rem-cube-cbrt20.0%
+-commutative20.0%
distribute-rgt-out19.9%
+-commutative19.9%
fma-define19.9%
add-exp-log19.9%
Applied egg-rr19.8%
associate-*r/19.8%
*-rgt-identity19.8%
+-commutative19.8%
associate--l+94.9%
+-commutative94.9%
+-commutative94.9%
Simplified94.9%
*-commutative94.9%
log1p-undefine94.9%
exp-to-pow94.7%
metadata-eval94.7%
metadata-eval94.7%
pow-sqr94.7%
+-commutative94.7%
metadata-eval94.7%
pow1/396.1%
+-commutative96.1%
metadata-eval96.1%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
pow1/394.7%
metadata-eval94.7%
add-sqr-sqrt94.7%
unpow-prod-down94.7%
metadata-eval94.7%
metadata-eval94.7%
Applied egg-rr94.7%
unpow1/396.1%
unpow1/398.4%
Simplified98.4%
fma-undefine98.4%
cbrt-unprod98.5%
add-sqr-sqrt98.4%
pow298.4%
cbrt-unprod98.8%
pow298.8%
Applied egg-rr98.8%
if 1.4e154 < x Initial program 4.8%
add-sqr-sqrt4.8%
pow24.8%
Applied egg-rr4.8%
Taylor expanded in x around inf 97.6%
unpow297.6%
associate-*l*97.8%
cbrt-div98.1%
metadata-eval98.1%
*-commutative98.1%
cbrt-div98.2%
metadata-eval98.2%
un-div-inv98.2%
Applied egg-rr98.2%
associate-*r/98.4%
unpow298.4%
Simplified98.4%
(FPCore (x)
:precision binary64
(if (<= x 2e+14)
(/
(+ 1.0 (- x x))
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ 1.0 x)))
(pow (+ 1.0 x) 0.6666666666666666)))
(* (/ 1.0 (cbrt x)) (/ (pow (sqrt 0.3333333333333333) 2.0) (cbrt x)))))
double code(double x) {
double tmp;
if (x <= 2e+14) {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((1.0 + x), 0.6666666666666666));
} else {
tmp = (1.0 / cbrt(x)) * (pow(sqrt(0.3333333333333333), 2.0) / cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 2e+14) tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(Float64(1.0 / cbrt(x)) * Float64((sqrt(0.3333333333333333) ^ 2.0) / cbrt(x))); end return tmp end
code[x_] := If[LessEqual[x, 2e+14], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $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] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Sqrt[0.3333333333333333], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x}} \cdot \frac{{\left(\sqrt{0.3333333333333333}\right)}^{2}}{\sqrt[3]{x}}\\
\end{array}
\end{array}
if x < 2e14Initial program 66.8%
flip3--74.6%
div-inv74.6%
rem-cube-cbrt71.9%
rem-cube-cbrt99.2%
+-commutative99.2%
distribute-rgt-out98.8%
+-commutative98.8%
fma-define98.7%
add-exp-log98.6%
Applied egg-rr98.3%
associate-*r/98.3%
*-rgt-identity98.3%
+-commutative98.3%
associate--l+98.3%
+-commutative98.3%
+-commutative98.3%
Simplified98.3%
*-commutative98.3%
log1p-undefine98.3%
exp-to-pow98.1%
Applied egg-rr98.1%
if 2e14 < x Initial program 4.3%
add-sqr-sqrt4.3%
pow24.3%
Applied egg-rr4.3%
Taylor expanded in x around inf 97.7%
unpow297.7%
associate-*l*97.8%
cbrt-div98.1%
metadata-eval98.1%
*-commutative98.1%
cbrt-div98.2%
metadata-eval98.2%
un-div-inv98.2%
Applied egg-rr98.2%
associate-*r/98.4%
unpow298.4%
Simplified98.4%
(FPCore (x) :precision binary64 (if (<= x 24000000.0) (- (cbrt (* x (+ 1.0 (/ 1.0 x)))) (cbrt x)) (* (/ 1.0 (cbrt x)) (/ (pow (sqrt 0.3333333333333333) 2.0) (cbrt x)))))
double code(double x) {
double tmp;
if (x <= 24000000.0) {
tmp = cbrt((x * (1.0 + (1.0 / x)))) - cbrt(x);
} else {
tmp = (1.0 / cbrt(x)) * (pow(sqrt(0.3333333333333333), 2.0) / cbrt(x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 24000000.0) {
tmp = Math.cbrt((x * (1.0 + (1.0 / x)))) - Math.cbrt(x);
} else {
tmp = (1.0 / Math.cbrt(x)) * (Math.pow(Math.sqrt(0.3333333333333333), 2.0) / Math.cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 24000000.0) tmp = Float64(cbrt(Float64(x * Float64(1.0 + Float64(1.0 / x)))) - cbrt(x)); else tmp = Float64(Float64(1.0 / cbrt(x)) * Float64((sqrt(0.3333333333333333) ^ 2.0) / cbrt(x))); end return tmp end
code[x_] := If[LessEqual[x, 24000000.0], N[(N[Power[N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Sqrt[0.3333333333333333], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 24000000:\\
\;\;\;\;\sqrt[3]{x \cdot \left(1 + \frac{1}{x}\right)} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x}} \cdot \frac{{\left(\sqrt{0.3333333333333333}\right)}^{2}}{\sqrt[3]{x}}\\
\end{array}
\end{array}
if x < 2.4e7Initial program 82.3%
Taylor expanded in x around inf 82.7%
if 2.4e7 < x Initial program 5.7%
add-sqr-sqrt5.7%
pow25.7%
Applied egg-rr5.7%
Taylor expanded in x around inf 96.9%
unpow296.9%
associate-*l*97.0%
cbrt-div97.3%
metadata-eval97.3%
*-commutative97.3%
cbrt-div97.4%
metadata-eval97.4%
un-div-inv97.5%
Applied egg-rr97.5%
associate-*r/97.6%
unpow297.6%
Simplified97.6%
(FPCore (x) :precision binary64 (if (<= x 24000000.0) (- (cbrt (* x (+ 1.0 (/ 1.0 x)))) (cbrt x)) (* 0.3333333333333333 (pow (cbrt x) -2.0))))
double code(double x) {
double tmp;
if (x <= 24000000.0) {
tmp = cbrt((x * (1.0 + (1.0 / x)))) - cbrt(x);
} else {
tmp = 0.3333333333333333 * pow(cbrt(x), -2.0);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 24000000.0) {
tmp = Math.cbrt((x * (1.0 + (1.0 / x)))) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.pow(Math.cbrt(x), -2.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 24000000.0) tmp = Float64(cbrt(Float64(x * Float64(1.0 + Float64(1.0 / x)))) - cbrt(x)); else tmp = Float64(0.3333333333333333 * (cbrt(x) ^ -2.0)); end return tmp end
code[x_] := If[LessEqual[x, 24000000.0], N[(N[Power[N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 24000000:\\
\;\;\;\;\sqrt[3]{x \cdot \left(1 + \frac{1}{x}\right)} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{-2}\\
\end{array}
\end{array}
if x < 2.4e7Initial program 82.3%
Taylor expanded in x around inf 82.7%
if 2.4e7 < x Initial program 5.7%
add-sqr-sqrt5.7%
pow25.7%
Applied egg-rr5.7%
Taylor expanded in x around inf 96.9%
add-sqr-sqrt96.9%
sqrt-unprod72.4%
pow-prod-up72.4%
*-commutative72.4%
cbrt-div72.7%
metadata-eval72.7%
un-div-inv72.8%
metadata-eval72.8%
Applied egg-rr72.8%
*-un-lft-identity72.8%
sqrt-pow197.4%
metadata-eval97.4%
pow297.4%
frac-times97.6%
rem-square-sqrt97.6%
pow297.6%
Applied egg-rr97.6%
*-lft-identity97.6%
rem-square-sqrt97.6%
unpow297.6%
times-frac97.4%
*-rgt-identity97.4%
associate-*l/97.4%
associate-*r/97.4%
*-rgt-identity97.4%
associate-*l/97.4%
associate-*r/97.3%
swap-sqr97.5%
rem-square-sqrt97.5%
unpow-197.5%
unpow-197.5%
pow-sqr97.6%
metadata-eval97.6%
Simplified97.6%
(FPCore (x) :precision binary64 (if (<= x 85000000.0) (- (cbrt (+ 1.0 x)) (cbrt x)) (* 0.3333333333333333 (pow (cbrt x) -2.0))))
double code(double x) {
double tmp;
if (x <= 85000000.0) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 0.3333333333333333 * pow(cbrt(x), -2.0);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 85000000.0) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.pow(Math.cbrt(x), -2.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 85000000.0) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = Float64(0.3333333333333333 * (cbrt(x) ^ -2.0)); end return tmp end
code[x_] := If[LessEqual[x, 85000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 85000000:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{-2}\\
\end{array}
\end{array}
if x < 8.5e7Initial program 82.3%
if 8.5e7 < x Initial program 5.7%
add-sqr-sqrt5.7%
pow25.7%
Applied egg-rr5.7%
Taylor expanded in x around inf 96.9%
add-sqr-sqrt96.9%
sqrt-unprod72.4%
pow-prod-up72.4%
*-commutative72.4%
cbrt-div72.7%
metadata-eval72.7%
un-div-inv72.8%
metadata-eval72.8%
Applied egg-rr72.8%
*-un-lft-identity72.8%
sqrt-pow197.4%
metadata-eval97.4%
pow297.4%
frac-times97.6%
rem-square-sqrt97.6%
pow297.6%
Applied egg-rr97.6%
*-lft-identity97.6%
rem-square-sqrt97.6%
unpow297.6%
times-frac97.4%
*-rgt-identity97.4%
associate-*l/97.4%
associate-*r/97.4%
*-rgt-identity97.4%
associate-*l/97.4%
associate-*r/97.3%
swap-sqr97.5%
rem-square-sqrt97.5%
unpow-197.5%
unpow-197.5%
pow-sqr97.6%
metadata-eval97.6%
Simplified97.6%
Final simplification96.9%
(FPCore (x) :precision binary64 (* 0.3333333333333333 (pow (cbrt x) -2.0)))
double code(double x) {
return 0.3333333333333333 * pow(cbrt(x), -2.0);
}
public static double code(double x) {
return 0.3333333333333333 * Math.pow(Math.cbrt(x), -2.0);
}
function code(x) return Float64(0.3333333333333333 * (cbrt(x) ^ -2.0)) end
code[x_] := N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{-2}
\end{array}
Initial program 9.0%
add-sqr-sqrt9.0%
pow29.0%
Applied egg-rr9.0%
Taylor expanded in x around inf 94.4%
add-sqr-sqrt94.4%
sqrt-unprod71.0%
pow-prod-up70.9%
*-commutative70.9%
cbrt-div71.2%
metadata-eval71.2%
un-div-inv71.3%
metadata-eval71.3%
Applied egg-rr71.3%
*-un-lft-identity71.3%
sqrt-pow194.8%
metadata-eval94.8%
pow294.8%
frac-times95.0%
rem-square-sqrt95.0%
pow295.0%
Applied egg-rr95.0%
*-lft-identity95.0%
rem-square-sqrt95.0%
unpow295.0%
times-frac94.8%
*-rgt-identity94.8%
associate-*l/94.8%
associate-*r/94.9%
*-rgt-identity94.9%
associate-*l/94.9%
associate-*r/94.8%
swap-sqr95.0%
rem-square-sqrt95.0%
unpow-195.0%
unpow-195.0%
pow-sqr95.0%
metadata-eval95.0%
Simplified95.0%
(FPCore (x) :precision binary64 (cbrt (* (pow x -2.0) 0.037037037037037035)))
double code(double x) {
return cbrt((pow(x, -2.0) * 0.037037037037037035));
}
public static double code(double x) {
return Math.cbrt((Math.pow(x, -2.0) * 0.037037037037037035));
}
function code(x) return cbrt(Float64((x ^ -2.0) * 0.037037037037037035)) end
code[x_] := N[Power[N[(N[Power[x, -2.0], $MachinePrecision] * 0.037037037037037035), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{{x}^{-2} \cdot 0.037037037037037035}
\end{array}
Initial program 9.0%
add-sqr-sqrt9.0%
pow29.0%
Applied egg-rr9.0%
Taylor expanded in x around inf 94.4%
*-un-lft-identity94.4%
*-commutative94.4%
unpow-prod-down94.7%
pow294.7%
rem-square-sqrt94.7%
pow294.7%
cbrt-unprod49.9%
inv-pow49.9%
inv-pow49.9%
pow-prod-up49.9%
metadata-eval49.9%
Applied egg-rr49.9%
*-lft-identity49.9%
rem-cbrt-cube49.5%
*-commutative49.5%
cube-prod49.4%
rem-cube-cbrt49.6%
metadata-eval49.8%
Simplified49.8%
(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 9.0%
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%
Taylor expanded in x around inf 5.5%
(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 2024152
(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)))