
(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 12 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 (+ x 1.0)))) (pow (pow (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)) -0.5) 2.0)))
double code(double x) {
double t_0 = cbrt((x + 1.0));
return pow(pow(fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0)), -0.5), 2.0);
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) return (fma(cbrt(x), Float64(cbrt(x) + t_0), (t_0 ^ 2.0)) ^ -0.5) ^ 2.0 end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, N[Power[N[Power[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], -0.5], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
{\left({\left(\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {t_0}^{2}\right)\right)}^{-0.5}\right)}^{2}
\end{array}
\end{array}
Initial program 55.5%
flip3--55.4%
div-inv55.4%
rem-cube-cbrt55.6%
rem-cube-cbrt56.8%
cbrt-unprod56.8%
pow256.8%
distribute-rgt-out56.8%
+-commutative56.8%
Applied egg-rr56.8%
associate-*r/56.8%
*-rgt-identity56.8%
+-commutative56.8%
associate--l+79.1%
+-inverses79.1%
metadata-eval79.1%
+-commutative79.1%
fma-def79.1%
+-commutative79.1%
+-commutative79.1%
Simplified79.1%
pow1/378.1%
+-commutative78.1%
pow-pow77.0%
pow-sqr77.0%
+-commutative77.0%
pow1/377.4%
+-commutative77.4%
pow1/399.2%
Applied egg-rr99.2%
unpow299.2%
Simplified99.2%
add-sqr-sqrt99.1%
pow299.1%
inv-pow99.1%
sqrt-pow199.2%
metadata-eval99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(if (<= (- (cbrt (+ x 1.0)) (cbrt x)) 4e-7)
(* 0.3333333333333333 (cbrt (/ 1.0 (* x x))))
(fma
(pow (+ x 1.0) 0.16666666666666666)
(cbrt (sqrt (+ x 1.0)))
(- (cbrt x)))))
double code(double x) {
double tmp;
if ((cbrt((x + 1.0)) - cbrt(x)) <= 4e-7) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = fma(pow((x + 1.0), 0.16666666666666666), cbrt(sqrt((x + 1.0))), -cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) <= 4e-7) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = fma((Float64(x + 1.0) ^ 0.16666666666666666), cbrt(sqrt(Float64(x + 1.0))), Float64(-cbrt(x))); end return tmp end
code[x_] := If[LessEqual[N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 4e-7], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(x + 1.0), $MachinePrecision], 0.16666666666666666], $MachinePrecision] * N[Power[N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] + (-N[Power[x, 1/3], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{x + 1} - \sqrt[3]{x} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\left(x + 1\right)}^{0.16666666666666666}, \sqrt[3]{\sqrt{x + 1}}, -\sqrt[3]{x}\right)\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.9999999999999998e-7Initial program 5.7%
add-sqr-sqrt2.7%
add-sqr-sqrt2.9%
difference-of-squares2.9%
pow1/32.9%
sqrt-pow12.9%
metadata-eval2.9%
pow1/32.9%
sqrt-pow12.9%
metadata-eval2.9%
pow1/31.6%
sqrt-pow11.6%
metadata-eval1.6%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
Applied egg-rr2.8%
Taylor expanded in x around inf 51.3%
unpow1/354.7%
unpow254.7%
Simplified54.7%
if 3.9999999999999998e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.4%
add-sqr-sqrt99.4%
fma-neg99.4%
pow1/399.4%
sqrt-pow199.4%
metadata-eval99.4%
pow1/399.4%
sqrt-pow199.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-sqr-sqrt99.4%
unpow-prod-down99.4%
+-commutative99.4%
+-commutative99.4%
Applied egg-rr99.4%
pow-sqr99.4%
metadata-eval99.4%
unpow1/399.4%
Simplified99.4%
Final simplification78.5%
(FPCore (x) :precision binary64 (if (<= (- (cbrt (+ x 1.0)) (cbrt x)) 4e-7) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) (- (sqrt (cbrt (pow (+ x 1.0) 2.0))) (cbrt x))))
double code(double x) {
double tmp;
if ((cbrt((x + 1.0)) - cbrt(x)) <= 4e-7) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = sqrt(cbrt(pow((x + 1.0), 2.0))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((Math.cbrt((x + 1.0)) - Math.cbrt(x)) <= 4e-7) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = Math.sqrt(Math.cbrt(Math.pow((x + 1.0), 2.0))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) <= 4e-7) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(sqrt(cbrt((Float64(x + 1.0) ^ 2.0))) - cbrt(x)); end return tmp end
code[x_] := If[LessEqual[N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 4e-7], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[Power[N[Power[N[(x + 1.0), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{x + 1} - \sqrt[3]{x} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt[3]{{\left(x + 1\right)}^{2}}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.9999999999999998e-7Initial program 5.7%
add-sqr-sqrt2.7%
add-sqr-sqrt2.9%
difference-of-squares2.9%
pow1/32.9%
sqrt-pow12.9%
metadata-eval2.9%
pow1/32.9%
sqrt-pow12.9%
metadata-eval2.9%
pow1/31.6%
sqrt-pow11.6%
metadata-eval1.6%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
Applied egg-rr2.8%
Taylor expanded in x around inf 51.3%
unpow1/354.7%
unpow254.7%
Simplified54.7%
if 3.9999999999999998e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.4%
add-sqr-sqrt99.4%
sqrt-unprod99.4%
cbrt-unprod99.4%
pow299.4%
Applied egg-rr99.4%
Final simplification78.5%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ x 1.0)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) 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[(x + 1.0), $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]{x + 1}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {t_0}^{2}\right)}
\end{array}
\end{array}
Initial program 55.5%
flip3--55.4%
div-inv55.4%
rem-cube-cbrt55.6%
rem-cube-cbrt56.8%
cbrt-unprod56.8%
pow256.8%
distribute-rgt-out56.8%
+-commutative56.8%
Applied egg-rr56.8%
associate-*r/56.8%
*-rgt-identity56.8%
+-commutative56.8%
associate--l+79.1%
+-inverses79.1%
metadata-eval79.1%
+-commutative79.1%
fma-def79.1%
+-commutative79.1%
+-commutative79.1%
Simplified79.1%
pow1/378.1%
+-commutative78.1%
pow-pow77.0%
pow-sqr77.0%
+-commutative77.0%
pow1/377.4%
+-commutative77.4%
pow1/399.2%
Applied egg-rr99.2%
unpow299.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ x 1.0)))))
(if (<= x 1.32e+154)
(/ 1.0 (+ (* (cbrt x) t_0) (cbrt (pow (+ x 1.0) 2.0))))
(/ 1.0 (fma (cbrt x) t_0 (pow (+ x 1.0) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((x + 1.0));
double tmp;
if (x <= 1.32e+154) {
tmp = 1.0 / ((cbrt(x) * t_0) + cbrt(pow((x + 1.0), 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow((x + 1.0), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(x + 1.0))) tmp = 0.0 if (x <= 1.32e+154) tmp = Float64(1.0 / Float64(Float64(cbrt(x) * t_0) + cbrt((Float64(x + 1.0) ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, (Float64(x + 1.0) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.32e+154], N[(1.0 / N[(N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Power[N[(x + 1.0), $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[(x + 1.0), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{x + 1}\\
\mathbf{if}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot t_0 + \sqrt[3]{{\left(x + 1\right)}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(x + 1\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.31999999999999998e154Initial program 63.0%
flip3--62.9%
div-inv62.9%
rem-cube-cbrt63.3%
rem-cube-cbrt64.5%
cbrt-unprod64.5%
pow264.5%
distribute-rgt-out64.5%
+-commutative64.5%
Applied egg-rr64.5%
associate-*r/64.5%
*-rgt-identity64.5%
+-commutative64.5%
associate--l+90.1%
+-inverses90.1%
metadata-eval90.1%
+-commutative90.1%
fma-def90.1%
+-commutative90.1%
+-commutative90.1%
Simplified90.1%
fma-udef90.1%
+-commutative90.1%
Applied egg-rr90.1%
if 1.31999999999999998e154 < x Initial program 4.6%
flip3--4.6%
div-inv4.6%
rem-cube-cbrt3.2%
rem-cube-cbrt4.6%
cbrt-unprod4.6%
pow24.6%
distribute-rgt-out4.6%
+-commutative4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
+-commutative4.6%
associate--l+4.6%
+-inverses4.6%
metadata-eval4.6%
+-commutative4.6%
fma-def4.6%
+-commutative4.6%
+-commutative4.6%
Simplified4.6%
pow1/34.6%
+-commutative4.6%
pow-pow91.7%
+-commutative91.7%
metadata-eval91.7%
Applied egg-rr91.7%
Final simplification90.3%
(FPCore (x)
:precision binary64
(if (<= x -1.0)
(* 0.3333333333333333 (cbrt (/ 1.0 (* x x))))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ x 1.0)))
(pow (+ x 1.0) 0.6666666666666666)))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((x + 1.0))), pow((x + 1.0), 0.6666666666666666));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(x + 1.0))), (Float64(x + 1.0) ^ 0.6666666666666666))); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x + 1}, {\left(x + 1\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1Initial program 6.1%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
difference-of-squares0.0%
pow1/30.0%
sqrt-pow10.0%
metadata-eval0.0%
pow1/30.0%
sqrt-pow10.0%
metadata-eval0.0%
pow1/30.0%
sqrt-pow10.0%
metadata-eval0.0%
pow1/30.0%
sqrt-pow10.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 55.7%
unpow1/359.3%
unpow259.3%
Simplified59.3%
if -1 < x Initial program 68.6%
flip3--68.6%
div-inv68.6%
rem-cube-cbrt68.7%
rem-cube-cbrt69.5%
cbrt-unprod69.5%
pow269.5%
distribute-rgt-out69.5%
+-commutative69.5%
Applied egg-rr69.5%
associate-*r/69.5%
*-rgt-identity69.5%
+-commutative69.5%
associate--l+84.1%
+-inverses84.1%
metadata-eval84.1%
+-commutative84.1%
fma-def84.1%
+-commutative84.1%
+-commutative84.1%
Simplified84.1%
pow1/383.4%
+-commutative83.4%
pow-pow97.6%
+-commutative97.6%
metadata-eval97.6%
Applied egg-rr97.6%
Final simplification89.5%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ x 1.0)) (cbrt x)))) (if (<= t_0 4e-7) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) t_0)))
double code(double x) {
double t_0 = cbrt((x + 1.0)) - cbrt(x);
double tmp;
if (t_0 <= 4e-7) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((x + 1.0)) - Math.cbrt(x);
double tmp;
if (t_0 <= 4e-7) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) tmp = 0.0 if (t_0 <= 4e-7) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = t_0; end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-7], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.9999999999999998e-7Initial program 5.7%
add-sqr-sqrt2.7%
add-sqr-sqrt2.9%
difference-of-squares2.9%
pow1/32.9%
sqrt-pow12.9%
metadata-eval2.9%
pow1/32.9%
sqrt-pow12.9%
metadata-eval2.9%
pow1/31.6%
sqrt-pow11.6%
metadata-eval1.6%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
Applied egg-rr2.8%
Taylor expanded in x around inf 51.3%
unpow1/354.7%
unpow254.7%
Simplified54.7%
if 3.9999999999999998e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.4%
Final simplification78.5%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.48))) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) (- 1.0 (cbrt x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 0.48)) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 0.48)) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.48)) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(1.0 - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.48]], $MachinePrecision]], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.48\right):\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1 or 0.47999999999999998 < x Initial program 7.4%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/33.4%
sqrt-pow13.3%
metadata-eval3.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 51.1%
unpow1/354.5%
unpow254.5%
Simplified54.5%
if -1 < x < 0.47999999999999998Initial program 99.9%
add-cube-cbrt99.9%
pow399.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 46.5%
metadata-eval46.5%
pow-base-146.5%
unpow1/398.6%
*-lft-identity98.6%
Simplified98.6%
Final simplification77.4%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) (+ 1.0 (- (* x 0.3333333333333333) (cbrt x)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 + ((x * 0.3333333333333333) - cbrt(x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 + ((x * 0.3333333333333333) - Math.cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(1.0 + Float64(Float64(x * 0.3333333333333333) - cbrt(x))); end return tmp end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x * 0.3333333333333333), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 7.4%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/33.4%
sqrt-pow13.3%
metadata-eval3.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 51.1%
unpow1/354.5%
unpow254.5%
Simplified54.5%
if -1 < x < 1Initial program 99.9%
add-cube-cbrt99.9%
pow399.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 47.0%
associate--l+47.0%
*-commutative47.0%
metadata-eval47.0%
pow-base-147.0%
unpow1/399.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification77.9%
(FPCore (x) :precision binary64 (- 1.0 (cbrt x)))
double code(double x) {
return 1.0 - cbrt(x);
}
public static double code(double x) {
return 1.0 - Math.cbrt(x);
}
function code(x) return Float64(1.0 - cbrt(x)) end
code[x_] := N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt[3]{x}
\end{array}
Initial program 55.5%
add-cube-cbrt55.3%
pow355.3%
Applied egg-rr55.3%
Taylor expanded in x around 0 24.6%
metadata-eval24.6%
pow-base-124.6%
unpow1/352.9%
*-lft-identity52.9%
Simplified52.9%
Final simplification52.9%
(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 55.5%
Taylor expanded in x around inf 3.6%
Final simplification3.6%
(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 55.5%
Taylor expanded in x around 0 52.1%
Final simplification52.1%
herbie shell --seed 2023223
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))