
(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)))) (/ 1.0 (+ (pow t_0 2.0) (* (cbrt x) (+ t_0 (cbrt x)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / (pow(t_0, 2.0) + (cbrt(x) * (t_0 + cbrt(x))));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * (t_0 + Math.cbrt(x))));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * Float64(t_0 + cbrt(x))))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{{t_0}^{2} + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}
\end{array}
\end{array}
Initial program 52.8%
add-cube-cbrt52.7%
pow352.7%
Applied egg-rr52.7%
rem-cube-cbrt52.8%
sub-neg52.8%
flip3-+52.8%
pow352.7%
add-cube-cbrt52.7%
+-commutative52.7%
pow252.7%
+-commutative52.7%
+-commutative52.7%
Applied egg-rr52.7%
cube-neg52.7%
rem-cube-cbrt53.2%
associate-+r+99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
*-commutative99.2%
cancel-sign-sub99.2%
sqr-neg99.2%
distribute-lft-in99.2%
+-commutative99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (cbrt x) (+ (cbrt (+ 1.0 x)) (cbrt x)))))
(if (<= x -1.35e+154)
(/ 1.0 (+ 1.0 t_0))
(if (<= x 1.32e+154)
(/ 1.0 (+ t_0 (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (+ t_0 (exp (* 0.6666666666666666 (log1p x)))))))))
double code(double x) {
double t_0 = cbrt(x) * (cbrt((1.0 + x)) + cbrt(x));
double tmp;
if (x <= -1.35e+154) {
tmp = 1.0 / (1.0 + t_0);
} else if (x <= 1.32e+154) {
tmp = 1.0 / (t_0 + cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / (t_0 + exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt(x) * (Math.cbrt((1.0 + x)) + Math.cbrt(x));
double tmp;
if (x <= -1.35e+154) {
tmp = 1.0 / (1.0 + t_0);
} else if (x <= 1.32e+154) {
tmp = 1.0 / (t_0 + Math.cbrt(Math.pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / (t_0 + Math.exp((0.6666666666666666 * Math.log1p(x))));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) * Float64(cbrt(Float64(1.0 + x)) + cbrt(x))) tmp = 0.0 if (x <= -1.35e+154) tmp = Float64(1.0 / Float64(1.0 + t_0)); elseif (x <= 1.32e+154) tmp = Float64(1.0 / Float64(t_0 + cbrt((Float64(1.0 + x) ^ 2.0)))); else tmp = Float64(1.0 / Float64(t_0 + exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.35e+154], N[(1.0 / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.32e+154], N[(1.0 / N[(t$95$0 + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right)\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{1 + t_0}\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{t_0 + \sqrt[3]{{\left(1 + x\right)}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0 + e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}}\\
\end{array}
\end{array}
if x < -1.35000000000000003e154Initial program 4.7%
add-cube-cbrt3.6%
pow33.6%
Applied egg-rr3.6%
rem-cube-cbrt4.7%
sub-neg4.7%
flip3-+4.7%
pow34.4%
add-cube-cbrt3.6%
+-commutative3.6%
pow23.6%
+-commutative3.6%
+-commutative3.6%
Applied egg-rr3.6%
cube-neg3.6%
rem-cube-cbrt4.7%
associate-+r+98.3%
sub-neg98.3%
+-inverses98.3%
metadata-eval98.3%
*-commutative98.3%
cancel-sign-sub98.3%
sqr-neg98.3%
distribute-lft-in98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 20.0%
if -1.35000000000000003e154 < x < 1.31999999999999998e154Initial program 69.2%
add-cube-cbrt69.5%
pow369.5%
Applied egg-rr69.5%
rem-cube-cbrt69.2%
sub-neg69.2%
flip3-+69.2%
pow369.2%
add-cube-cbrt69.5%
+-commutative69.5%
pow269.5%
+-commutative69.5%
+-commutative69.5%
Applied egg-rr69.5%
cube-neg69.5%
rem-cube-cbrt69.7%
associate-+r+99.4%
sub-neg99.4%
+-inverses99.4%
metadata-eval99.4%
*-commutative99.4%
cancel-sign-sub99.4%
sqr-neg99.4%
distribute-lft-in99.4%
+-commutative99.4%
Simplified99.4%
unpow299.4%
cbrt-unprod99.6%
pow299.6%
+-commutative99.6%
Applied egg-rr99.6%
if 1.31999999999999998e154 < x Initial program 4.7%
add-cube-cbrt2.7%
pow32.9%
Applied egg-rr2.9%
rem-cube-cbrt4.7%
sub-neg4.7%
flip3-+4.7%
pow34.1%
add-cube-cbrt2.9%
+-commutative2.9%
pow22.9%
+-commutative2.9%
+-commutative2.9%
Applied egg-rr2.9%
cube-neg2.9%
rem-cube-cbrt4.7%
associate-+r+98.4%
sub-neg98.4%
+-inverses98.4%
metadata-eval98.4%
*-commutative98.4%
cancel-sign-sub98.4%
sqr-neg98.4%
distribute-lft-in98.4%
+-commutative98.4%
Simplified98.4%
pow1/391.6%
pow-pow91.6%
metadata-eval91.6%
add-exp-log91.8%
log-pow91.6%
log1p-udef91.6%
Applied egg-rr91.6%
Final simplification88.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x)))
(t_1 (/ 1.0 (+ 1.0 (* (cbrt x) (+ t_0 (cbrt x)))))))
(if (<= x 1.0)
t_1
(if (<= x 1.32e+154)
(/ 1.0 (fma (cbrt x) (+ t_0 (pow x 0.3333333333333333)) (cbrt (* x x))))
t_1))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = 1.0 / (1.0 + (cbrt(x) * (t_0 + cbrt(x))));
double tmp;
if (x <= 1.0) {
tmp = t_1;
} else if (x <= 1.32e+154) {
tmp = 1.0 / fma(cbrt(x), (t_0 + pow(x, 0.3333333333333333)), cbrt((x * x)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(t_0 + cbrt(x))))) tmp = 0.0 if (x <= 1.0) tmp = t_1; elseif (x <= 1.32e+154) tmp = Float64(1.0 / fma(cbrt(x), Float64(t_0 + (x ^ 0.3333333333333333)), cbrt(Float64(x * x)))); else tmp = t_1; 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[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.0], t$95$1, If[LessEqual[x, 1.32e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision] + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\
\mathbf{if}\;x \leq 1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0 + {x}^{0.3333333333333333}, \sqrt[3]{x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < 1 or 1.31999999999999998e154 < x Initial program 59.4%
add-cube-cbrt59.2%
pow359.2%
Applied egg-rr59.2%
rem-cube-cbrt59.4%
sub-neg59.4%
flip3-+59.3%
pow359.2%
add-cube-cbrt59.2%
+-commutative59.2%
pow259.2%
+-commutative59.2%
+-commutative59.2%
Applied egg-rr59.2%
cube-neg59.2%
rem-cube-cbrt59.4%
associate-+r+99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
*-commutative99.2%
cancel-sign-sub99.2%
sqr-neg99.2%
distribute-lft-in99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 64.7%
if 1 < x < 1.31999999999999998e154Initial program 7.0%
flip3--7.0%
div-inv7.0%
rem-cube-cbrt7.3%
rem-cube-cbrt9.5%
cbrt-unprod9.6%
pow29.6%
distribute-rgt-out9.6%
+-commutative9.6%
Applied egg-rr9.6%
associate-*r/9.6%
*-rgt-identity9.6%
+-commutative9.6%
associate--l+98.9%
+-inverses98.9%
metadata-eval98.9%
+-commutative98.9%
fma-def98.9%
+-commutative98.9%
+-commutative98.9%
Simplified98.9%
pow1/395.8%
Applied egg-rr95.8%
pow1/393.4%
pow-pow93.4%
metadata-eval93.4%
Applied egg-rr93.4%
Taylor expanded in x around inf 91.0%
unpow1/393.3%
unpow293.3%
Simplified93.3%
Final simplification68.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (cbrt x) (+ (cbrt (+ 1.0 x)) (cbrt x)))))
(if (<= x -1.0)
(/ 1.0 (+ 1.0 t_0))
(/ 1.0 (+ t_0 (exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double t_0 = cbrt(x) * (cbrt((1.0 + x)) + cbrt(x));
double tmp;
if (x <= -1.0) {
tmp = 1.0 / (1.0 + t_0);
} else {
tmp = 1.0 / (t_0 + exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt(x) * (Math.cbrt((1.0 + x)) + Math.cbrt(x));
double tmp;
if (x <= -1.0) {
tmp = 1.0 / (1.0 + t_0);
} else {
tmp = 1.0 / (t_0 + Math.exp((0.6666666666666666 * Math.log1p(x))));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) * Float64(cbrt(Float64(1.0 + x)) + cbrt(x))) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 / Float64(1.0 + t_0)); else tmp = Float64(1.0 / Float64(t_0 + exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(1.0 / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right)\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{1}{1 + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0 + e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}}\\
\end{array}
\end{array}
if x < -1Initial program 4.1%
add-cube-cbrt4.4%
pow34.4%
Applied egg-rr4.4%
rem-cube-cbrt4.1%
sub-neg4.1%
flip3-+4.1%
pow34.0%
add-cube-cbrt4.4%
+-commutative4.4%
pow24.4%
+-commutative4.4%
+-commutative4.4%
Applied egg-rr4.4%
cube-neg4.4%
rem-cube-cbrt4.4%
associate-+r+98.4%
sub-neg98.4%
+-inverses98.4%
metadata-eval98.4%
*-commutative98.4%
cancel-sign-sub98.4%
sqr-neg98.4%
distribute-lft-in98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 20.0%
if -1 < x Initial program 69.1%
add-cube-cbrt68.8%
pow368.8%
Applied egg-rr68.8%
rem-cube-cbrt69.1%
sub-neg69.1%
flip3-+69.0%
pow369.0%
add-cube-cbrt68.8%
+-commutative68.8%
pow268.8%
+-commutative68.8%
+-commutative68.8%
Applied egg-rr68.8%
cube-neg68.8%
rem-cube-cbrt69.4%
associate-+r+99.4%
sub-neg99.4%
+-inverses99.4%
metadata-eval99.4%
*-commutative99.4%
cancel-sign-sub99.4%
sqr-neg99.4%
distribute-lft-in99.4%
+-commutative99.4%
Simplified99.4%
pow1/397.6%
pow-pow97.6%
metadata-eval97.6%
add-exp-log97.7%
log-pow97.6%
log1p-udef97.6%
Applied egg-rr97.6%
Final simplification78.2%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 1e-10) (cbrt (/ 1.0 (* x x))) t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 1e-10) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x)) - Math.cbrt(x);
double tmp;
if (t_0 <= 1e-10) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) tmp = 0.0 if (t_0 <= 1e-10) tmp = 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[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-10], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 10^{-10}:\\
\;\;\;\;\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)) < 1.00000000000000004e-10Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt4.0%
rem-cube-cbrt5.0%
cbrt-unprod5.0%
pow25.0%
distribute-rgt-out5.0%
+-commutative5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+50.3%
+-inverses50.3%
metadata-eval50.3%
+-commutative50.3%
fma-def50.3%
+-commutative50.3%
+-commutative50.3%
Simplified50.3%
add-sqr-sqrt50.2%
sqrt-unprod50.3%
inv-pow50.3%
inv-pow50.3%
pow-prod-up50.3%
Applied egg-rr36.0%
Taylor expanded in x around inf 11.0%
unpow1/311.0%
unpow211.0%
Simplified11.0%
if 1.00000000000000004e-10 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.9%
Final simplification56.2%
(FPCore (x) :precision binary64 (/ 1.0 (+ 1.0 (* (cbrt x) (+ (cbrt (+ 1.0 x)) (cbrt x))))))
double code(double x) {
return 1.0 / (1.0 + (cbrt(x) * (cbrt((1.0 + x)) + cbrt(x))));
}
public static double code(double x) {
return 1.0 / (1.0 + (Math.cbrt(x) * (Math.cbrt((1.0 + x)) + Math.cbrt(x))));
}
function code(x) return Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(cbrt(Float64(1.0 + x)) + cbrt(x))))) end
code[x_] := N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right)}
\end{array}
Initial program 52.8%
add-cube-cbrt52.7%
pow352.7%
Applied egg-rr52.7%
rem-cube-cbrt52.8%
sub-neg52.8%
flip3-+52.8%
pow352.7%
add-cube-cbrt52.7%
+-commutative52.7%
pow252.7%
+-commutative52.7%
+-commutative52.7%
Applied egg-rr52.7%
cube-neg52.7%
rem-cube-cbrt53.2%
associate-+r+99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
*-commutative99.2%
cancel-sign-sub99.2%
sqr-neg99.2%
distribute-lft-in99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 59.1%
Final simplification59.1%
(FPCore (x) :precision binary64 (if (or (<= x -0.95) (not (<= x 2.7))) (cbrt (/ 1.0 (* x x))) (+ 1.0 (- (* x 0.3333333333333333) (cbrt x)))))
double code(double x) {
double tmp;
if ((x <= -0.95) || !(x <= 2.7)) {
tmp = 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 <= -0.95) || !(x <= 2.7)) {
tmp = 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 <= -0.95) || !(x <= 2.7)) tmp = 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, -0.95], N[Not[LessEqual[x, 2.7]], $MachinePrecision]], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $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 -0.95 \lor \neg \left(x \leq 2.7\right):\\
\;\;\;\;\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 < -0.94999999999999996 or 2.7000000000000002 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt4.0%
rem-cube-cbrt5.0%
cbrt-unprod5.0%
pow25.0%
distribute-rgt-out5.0%
+-commutative5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+50.3%
+-inverses50.3%
metadata-eval50.3%
+-commutative50.3%
fma-def50.3%
+-commutative50.3%
+-commutative50.3%
Simplified50.3%
add-sqr-sqrt50.2%
sqrt-unprod50.3%
inv-pow50.3%
inv-pow50.3%
pow-prod-up50.3%
Applied egg-rr36.0%
Taylor expanded in x around inf 11.0%
unpow1/311.0%
unpow211.0%
Simplified11.0%
if -0.94999999999999996 < x < 2.7000000000000002Initial program 99.9%
add-cube-cbrt99.9%
pow399.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 45.9%
associate--l+45.9%
*-commutative45.9%
metadata-eval45.9%
pow-base-145.9%
unpow1/398.7%
*-lft-identity98.7%
Simplified98.7%
Final simplification55.6%
(FPCore (x) :precision binary64 (if (<= x 0.8) (- 1.0 (cbrt x)) (cbrt (/ 1.0 (* x x)))))
double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = 1.0 - cbrt(x);
} else {
tmp = cbrt((1.0 / (x * x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = 1.0 - Math.cbrt(x);
} else {
tmp = Math.cbrt((1.0 / (x * x)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 0.8) tmp = Float64(1.0 - cbrt(x)); else tmp = cbrt(Float64(1.0 / Float64(x * x))); end return tmp end
code[x_] := If[LessEqual[x, 0.8], N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.8:\\
\;\;\;\;1 - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\end{array}
\end{array}
if x < 0.80000000000000004Initial program 68.2%
add-cube-cbrt68.3%
pow368.2%
Applied egg-rr68.2%
Taylor expanded in x around 0 30.4%
metadata-eval30.4%
pow-base-130.4%
unpow1/367.1%
*-lft-identity67.1%
Simplified67.1%
if 0.80000000000000004 < x Initial program 5.9%
flip3--5.9%
div-inv5.9%
rem-cube-cbrt5.2%
rem-cube-cbrt7.2%
cbrt-unprod7.2%
pow27.2%
distribute-rgt-out7.2%
+-commutative7.2%
Applied egg-rr7.2%
associate-*r/7.2%
*-rgt-identity7.2%
+-commutative7.2%
associate--l+52.6%
+-inverses52.6%
metadata-eval52.6%
+-commutative52.6%
fma-def52.6%
+-commutative52.6%
+-commutative52.6%
Simplified52.6%
add-sqr-sqrt52.3%
sqrt-unprod52.6%
inv-pow52.6%
inv-pow52.6%
pow-prod-up52.6%
Applied egg-rr73.5%
Taylor expanded in x around inf 11.3%
unpow1/311.3%
unpow211.3%
Simplified11.3%
Final simplification53.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 52.8%
add-cube-cbrt52.7%
pow352.7%
Applied egg-rr52.7%
Taylor expanded in x around 0 23.4%
metadata-eval23.4%
pow-base-123.4%
unpow1/351.1%
*-lft-identity51.1%
Simplified51.1%
Final simplification51.1%
(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 52.8%
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 52.8%
Taylor expanded in x around 0 50.0%
Final simplification50.0%
herbie shell --seed 2023279
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))