
(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 10 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))))
(if (<= x 5e+63)
(/
1.0
(fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 5e+63) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 5e+63) 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 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 5e+63], 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[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 5 \cdot 10^{+63}:\\
\;\;\;\;\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}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 5.00000000000000011e63Initial program 17.9%
flip3--20.1%
div-inv20.1%
rem-cube-cbrt19.1%
rem-cube-cbrt28.0%
+-commutative28.0%
distribute-rgt-out28.0%
+-commutative28.0%
fma-define28.0%
add-exp-log27.8%
Applied egg-rr27.8%
associate-*r/27.8%
*-rgt-identity27.8%
+-commutative27.8%
associate--l+96.1%
+-inverses96.1%
metadata-eval96.1%
+-commutative96.1%
exp-prod95.1%
Simplified95.1%
pow-exp96.1%
*-commutative96.1%
log1p-undefine96.1%
+-commutative96.1%
exp-to-pow96.1%
metadata-eval96.1%
pow-sqr96.2%
pow1/397.3%
pow1/398.8%
cbrt-unprod99.1%
pow299.1%
Applied egg-rr99.1%
if 5.00000000000000011e63 < x Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt2.9%
rem-cube-cbrt4.4%
+-commutative4.4%
distribute-rgt-out4.4%
+-commutative4.4%
fma-define4.4%
add-exp-log4.4%
Applied egg-rr4.4%
associate-*r/4.4%
*-rgt-identity4.4%
+-commutative4.4%
associate--l+92.5%
+-inverses92.5%
metadata-eval92.5%
+-commutative92.5%
exp-prod91.7%
Simplified91.7%
Taylor expanded in x around inf 91.7%
Taylor expanded in x around inf 98.9%
Final simplification99.0%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (sqrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (* t_0 t_0)) (pow (cbrt (+ 1.0 x)) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + (t_0 * t_0)), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(t_0 * t_0)), (cbrt(Float64(1.0 + x)) ^ 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[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $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} + t\_0 \cdot t\_0, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 7.5%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt6.6%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.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.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.3%
+-commutative93.3%
exp-to-pow93.1%
metadata-eval93.1%
pow-sqr93.1%
pow1/394.5%
pow1/398.6%
Applied egg-rr98.6%
pow1/394.5%
+-commutative94.5%
add-sqr-sqrt94.5%
unpow-prod-down94.5%
+-commutative94.5%
add-sqr-sqrt94.5%
hypot-1-def94.5%
+-commutative94.5%
add-sqr-sqrt94.5%
hypot-1-def94.5%
Applied egg-rr94.5%
unpow1/395.9%
hypot-undefine95.9%
metadata-eval95.9%
rem-square-sqrt95.9%
unpow1/398.7%
hypot-undefine98.7%
metadata-eval98.7%
rem-square-sqrt98.7%
Simplified98.7%
pow298.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (cbrt (/ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (* x (+ t_1 (* 2.0 t_1))))
(/
1.0
(fma (cbrt x) (+ (cbrt x) t_0) (pow (+ 1.0 x) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt((1.0 / x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / (x * (t_1 + (2.0 * t_1)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / Float64(x * Float64(t_1 + Float64(2.0 * t_1)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (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[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(x * N[(t$95$1 + N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_1 + 2 \cdot t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.0%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-define4.2%
add-exp-log4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.1%
Simplified92.1%
Taylor expanded in x around inf 92.1%
Taylor expanded in x around inf 98.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 59.6%
flip3--68.1%
div-inv68.1%
rem-cube-cbrt64.1%
rem-cube-cbrt98.6%
+-commutative98.6%
distribute-rgt-out98.8%
+-commutative98.8%
fma-define98.7%
add-exp-log97.9%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
+-commutative98.1%
associate--l+98.1%
+-inverses98.1%
metadata-eval98.1%
+-commutative98.1%
exp-prod97.6%
Simplified97.6%
pow-exp98.1%
*-commutative98.1%
log1p-undefine98.1%
+-commutative98.1%
exp-to-pow98.2%
metadata-eval98.2%
pow-sqr98.3%
pow1/398.6%
pow1/398.7%
Applied egg-rr98.7%
pow298.7%
pow1/398.3%
pow-pow98.2%
metadata-eval98.2%
Applied egg-rr98.2%
Final simplification98.9%
(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.5%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt6.6%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.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.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.3%
+-commutative93.3%
exp-to-pow93.1%
metadata-eval93.1%
pow-sqr93.1%
pow1/394.5%
pow1/398.6%
Applied egg-rr98.6%
pow298.7%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (/ 1.0 x))))
(if (<= x 7.5e+15)
(/
(- (+ 1.0 x) x)
(+
(cbrt (pow (+ 1.0 x) 2.0))
(* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))))))
(/ 1.0 (* x (+ t_0 (* 2.0 t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
double tmp;
if (x <= 7.5e+15) {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 / x));
double tmp;
if (x <= 7.5e+15) {
tmp = ((1.0 + x) - x) / (Math.cbrt(Math.pow((1.0 + x), 2.0)) + (Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
} else {
tmp = 1.0 / (x * (t_0 + (2.0 * t_0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) tmp = 0.0 if (x <= 7.5e+15) tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))); else tmp = Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 7.5e+15], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / 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] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\mathbf{if}\;x \leq 7.5 \cdot 10^{+15}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 7.5e15Initial program 59.6%
pow1/357.1%
add-sqr-sqrt57.4%
pow257.4%
pow-pow57.2%
metadata-eval57.2%
Applied egg-rr57.2%
metadata-eval57.2%
pow-sqr56.9%
pow1/358.4%
pow1/359.0%
pow1/358.4%
sqrt-pow258.4%
metadata-eval58.4%
flip3--58.4%
Applied egg-rr99.0%
if 7.5e15 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.0%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-define4.2%
add-exp-log4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.1%
Simplified92.1%
Taylor expanded in x around inf 92.1%
Taylor expanded in x around inf 98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (/ 1.0 x)))) (/ 1.0 (* x (+ t_0 (* 2.0 t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 / x));
return 1.0 / (x * (t_0 + (2.0 * t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 / x));
return 1.0 / (x * (t_0 + (2.0 * t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 / x)) return Float64(1.0 / Float64(x * Float64(t_0 + Float64(2.0 * t_0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(x * N[(t$95$0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{x}}\\
\frac{1}{x \cdot \left(t\_0 + 2 \cdot t\_0\right)}
\end{array}
\end{array}
Initial program 7.5%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt6.6%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.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.5%
Simplified92.5%
Taylor expanded in x around inf 90.4%
Taylor expanded in x around inf 96.6%
(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.5%
Taylor expanded in x around inf 49.1%
(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.5%
Final simplification7.5%
(FPCore (x) :precision binary64 (+ 1.0 (+ (cbrt x) -1.0)))
double code(double x) {
return 1.0 + (cbrt(x) + -1.0);
}
public static double code(double x) {
return 1.0 + (Math.cbrt(x) + -1.0);
}
function code(x) return Float64(1.0 + Float64(cbrt(x) + -1.0)) end
code[x_] := N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\sqrt[3]{x} + -1\right)
\end{array}
Initial program 7.5%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.4%
fabs-neg5.4%
unpow1/35.4%
metadata-eval5.4%
pow-sqr5.4%
fabs-sqr5.4%
pow-sqr5.4%
metadata-eval5.4%
unpow1/35.4%
Simplified5.4%
pow1/35.4%
Applied egg-rr5.4%
pow1/35.4%
expm1-log1p-u5.4%
expm1-undefine5.4%
Applied egg-rr5.4%
Simplified5.4%
(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 7.5%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.4%
fabs-neg5.4%
unpow1/35.4%
metadata-eval5.4%
pow-sqr5.4%
fabs-sqr5.4%
pow-sqr5.4%
metadata-eval5.4%
unpow1/35.4%
Simplified5.4%
(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 2024088
(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)))