
(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 15 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 (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (- x -1.0))) (pow (/ 1.0 (cbrt (/ 1.0 (+ 1.0 x)))) 2.0))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((x - -1.0))), pow((1.0 / cbrt((1.0 / (1.0 + x)))), 2.0));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(x - -1.0))), (Float64(1.0 / cbrt(Float64(1.0 / 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] + N[Power[N[(x - -1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(1.0 / N[Power[N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x - -1}, {\left(\frac{1}{\sqrt[3]{\frac{1}{1 + x}}}\right)}^{2}\right)}
\end{array}
Initial program 50.8%
pow1/348.2%
flip-+48.5%
div-inv48.5%
unpow-prod-down2.1%
pow1/32.9%
fma-neg2.9%
metadata-eval2.9%
fma-neg2.9%
metadata-eval2.9%
sub-neg2.9%
metadata-eval2.9%
Applied egg-rr2.9%
Applied egg-rr99.2%
sub-neg99.2%
metadata-eval99.2%
flip-+75.0%
clear-num75.0%
cbrt-div75.0%
metadata-eval75.0%
clear-num75.0%
flip-+99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(if (<= (- (cbrt (+ 1.0 x)) (cbrt x)) 0.0)
(* 0.3333333333333333 (/ (cbrt (/ -1.0 x)) (cbrt (- x))))
(/
1.0
(fma (cbrt x) (+ (cbrt x) (cbrt (- x -1.0))) (cbrt (pow (+ 1.0 x) 2.0))))))
double code(double x) {
double tmp;
if ((cbrt((1.0 + x)) - cbrt(x)) <= 0.0) {
tmp = 0.3333333333333333 * (cbrt((-1.0 / x)) / cbrt(-x));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((x - -1.0))), cbrt(pow((1.0 + x), 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) <= 0.0) tmp = Float64(0.3333333333333333 * Float64(cbrt(Float64(-1.0 / x)) / cbrt(Float64(-x)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(x - -1.0))), cbrt((Float64(1.0 + x) ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(0.3333333333333333 * N[(N[Power[N[(-1.0 / x), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[(-x), 1/3], $MachinePrecision]), $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[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 0:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt[3]{\frac{-1}{x}}}{\sqrt[3]{-x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x - -1}, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
pow1/31.0%
rem-cube-cbrt1.0%
sqr-pow1.0%
pow1/32.1%
sqr-pow2.2%
difference-of-squares2.2%
*-commutative2.2%
rem-cube-cbrt2.2%
metadata-eval2.2%
metadata-eval2.2%
+-commutative2.2%
metadata-eval2.2%
rem-cube-cbrt2.2%
metadata-eval2.2%
Applied egg-rr2.2%
Taylor expanded in x around inf 44.6%
unpow1/347.9%
unpow247.9%
Simplified47.9%
associate-/r*49.7%
frac-2neg49.7%
cbrt-div98.6%
Applied egg-rr98.6%
distribute-neg-frac98.6%
metadata-eval98.6%
Simplified98.6%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 93.3%
pow1/391.2%
flip-+91.2%
div-inv91.1%
unpow-prod-down3.1%
pow1/33.3%
fma-neg3.2%
metadata-eval3.2%
fma-neg3.2%
metadata-eval3.2%
sub-neg3.2%
metadata-eval3.2%
Applied egg-rr3.2%
Applied egg-rr99.8%
unpow299.8%
cbrt-unprod99.8%
pow299.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.2%
(FPCore (x)
:precision binary64
(if (<= (- (cbrt (+ 1.0 x)) (cbrt x)) 5e-8)
(* 0.3333333333333333 (/ (cbrt (/ -1.0 x)) (cbrt (- x))))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (- x -1.0)))
(exp (* 0.6666666666666666 (log1p x)))))))
double code(double x) {
double tmp;
if ((cbrt((1.0 + x)) - cbrt(x)) <= 5e-8) {
tmp = 0.3333333333333333 * (cbrt((-1.0 / x)) / cbrt(-x));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((x - -1.0))), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) <= 5e-8) tmp = Float64(0.3333333333333333 * Float64(cbrt(Float64(-1.0 / x)) / cbrt(Float64(-x)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(x - -1.0))), exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := If[LessEqual[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-8], N[(0.3333333333333333 * N[(N[Power[N[(-1.0 / x), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[(-x), 1/3], $MachinePrecision]), $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[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt[3]{\frac{-1}{x}}}{\sqrt[3]{-x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x - -1}, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.9999999999999998e-8Initial program 6.3%
pow1/31.6%
rem-cube-cbrt1.6%
sqr-pow1.7%
pow1/32.9%
sqr-pow3.0%
difference-of-squares3.0%
*-commutative3.0%
rem-cube-cbrt3.1%
metadata-eval3.1%
metadata-eval3.1%
+-commutative3.1%
metadata-eval3.1%
rem-cube-cbrt3.1%
metadata-eval3.1%
Applied egg-rr3.1%
Taylor expanded in x around inf 47.8%
unpow1/350.9%
unpow250.9%
Simplified50.9%
associate-/r*52.5%
frac-2neg52.5%
cbrt-div97.7%
Applied egg-rr97.7%
distribute-neg-frac97.7%
metadata-eval97.7%
Simplified97.7%
if 4.9999999999999998e-8 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
pow1/397.7%
flip-+97.7%
div-inv97.7%
unpow-prod-down2.6%
pow1/32.6%
fma-neg2.6%
metadata-eval2.6%
fma-neg2.6%
metadata-eval2.6%
sub-neg2.6%
metadata-eval2.6%
Applied egg-rr2.6%
Applied egg-rr99.9%
pow-to-exp99.1%
*-commutative99.1%
pow1/399.1%
log-pow99.1%
sub-neg99.1%
metadata-eval99.1%
+-commutative99.1%
log1p-def99.1%
Applied egg-rr99.1%
associate-*r*99.1%
metadata-eval99.1%
Simplified99.1%
Final simplification98.4%
(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 50.8%
pow1/348.2%
flip-+48.5%
div-inv48.5%
unpow-prod-down2.1%
pow1/32.9%
fma-neg2.9%
metadata-eval2.9%
fma-neg2.9%
metadata-eval2.9%
sub-neg2.9%
metadata-eval2.9%
Applied egg-rr2.9%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 5e-7)
(* 0.3333333333333333 (/ (cbrt (/ -1.0 x)) (cbrt (- x))))
(/ 1.0 (/ 1.0 t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 5e-7) {
tmp = 0.3333333333333333 * (cbrt((-1.0 / x)) / cbrt(-x));
} else {
tmp = 1.0 / (1.0 / 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 <= 5e-7) {
tmp = 0.3333333333333333 * (Math.cbrt((-1.0 / x)) / Math.cbrt(-x));
} else {
tmp = 1.0 / (1.0 / t_0);
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) tmp = 0.0 if (t_0 <= 5e-7) tmp = Float64(0.3333333333333333 * Float64(cbrt(Float64(-1.0 / x)) / cbrt(Float64(-x)))); else tmp = Float64(1.0 / Float64(1.0 / 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, 5e-7], N[(0.3333333333333333 * N[(N[Power[N[(-1.0 / x), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[(-x), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt[3]{\frac{-1}{x}}}{\sqrt[3]{-x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t_0}}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.99999999999999977e-7Initial program 7.2%
pow1/32.7%
rem-cube-cbrt2.6%
sqr-pow2.6%
pow1/33.9%
sqr-pow4.0%
difference-of-squares4.0%
*-commutative4.0%
rem-cube-cbrt4.1%
metadata-eval4.1%
metadata-eval4.1%
+-commutative4.1%
metadata-eval4.1%
rem-cube-cbrt4.1%
metadata-eval4.1%
Applied egg-rr4.1%
Taylor expanded in x around inf 48.3%
unpow1/351.3%
unpow251.3%
Simplified51.3%
associate-/r*52.9%
frac-2neg52.9%
cbrt-div97.1%
Applied egg-rr97.1%
distribute-neg-frac97.1%
metadata-eval97.1%
Simplified97.1%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.5%
remove-double-div99.5%
Applied egg-rr99.5%
Final simplification98.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 5e-7)
(* 0.3333333333333333 (/ (cbrt (/ -1.0 x)) (cbrt (- x))))
t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 5e-7) {
tmp = 0.3333333333333333 * (cbrt((-1.0 / x)) / cbrt(-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 <= 5e-7) {
tmp = 0.3333333333333333 * (Math.cbrt((-1.0 / x)) / Math.cbrt(-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 <= 5e-7) tmp = Float64(0.3333333333333333 * Float64(cbrt(Float64(-1.0 / x)) / cbrt(Float64(-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, 5e-7], N[(0.3333333333333333 * N[(N[Power[N[(-1.0 / x), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[(-x), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt[3]{\frac{-1}{x}}}{\sqrt[3]{-x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.99999999999999977e-7Initial program 7.2%
pow1/32.7%
rem-cube-cbrt2.6%
sqr-pow2.6%
pow1/33.9%
sqr-pow4.0%
difference-of-squares4.0%
*-commutative4.0%
rem-cube-cbrt4.1%
metadata-eval4.1%
metadata-eval4.1%
+-commutative4.1%
metadata-eval4.1%
rem-cube-cbrt4.1%
metadata-eval4.1%
Applied egg-rr4.1%
Taylor expanded in x around inf 48.3%
unpow1/351.3%
unpow251.3%
Simplified51.3%
associate-/r*52.9%
frac-2neg52.9%
cbrt-div97.1%
Applied egg-rr97.1%
distribute-neg-frac97.1%
metadata-eval97.1%
Simplified97.1%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.5%
Final simplification98.2%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 5e-7) (/ 0.3333333333333333 (pow (cbrt x) 2.0)) t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 5e-7) {
tmp = 0.3333333333333333 / pow(cbrt(x), 2.0);
} 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 <= 5e-7) {
tmp = 0.3333333333333333 / Math.pow(Math.cbrt(x), 2.0);
} 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 <= 5e-7) tmp = Float64(0.3333333333333333 / (cbrt(x) ^ 2.0)); 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, 5e-7], N[(0.3333333333333333 / N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.3333333333333333}{{\left(\sqrt[3]{x}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.99999999999999977e-7Initial program 7.2%
pow1/32.7%
rem-cube-cbrt2.6%
sqr-pow2.6%
pow1/33.9%
sqr-pow4.0%
difference-of-squares4.0%
*-commutative4.0%
rem-cube-cbrt4.1%
metadata-eval4.1%
metadata-eval4.1%
+-commutative4.1%
metadata-eval4.1%
rem-cube-cbrt4.1%
metadata-eval4.1%
Applied egg-rr4.1%
Taylor expanded in x around inf 48.3%
unpow1/351.3%
unpow251.3%
Simplified51.3%
cbrt-div51.4%
metadata-eval51.4%
cbrt-prod96.9%
un-div-inv96.9%
unpow296.9%
Applied egg-rr96.9%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.5%
Final simplification98.1%
(FPCore (x)
:precision binary64
(if (or (<= x -1.0) (not (<= x 1.0)))
(* 0.3333333333333333 (cbrt (pow x -2.0)))
(-
(+ 1.0 (* x (+ 0.3333333333333333 (* x -0.1111111111111111))))
(cbrt x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * cbrt(pow(x, -2.0));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * Math.cbrt(Math.pow(x, -2.0));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(0.3333333333333333 * cbrt((x ^ -2.0))); else tmp = Float64(Float64(1.0 + Float64(x * Float64(0.3333333333333333 + Float64(x * -0.1111111111111111)))) - 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[Power[x, -2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * N[(0.3333333333333333 + N[(x * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $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]{{x}^{-2}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(0.3333333333333333 + x \cdot -0.1111111111111111\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.9%
pow1/33.9%
rem-cube-cbrt3.9%
sqr-pow3.9%
pow1/35.1%
sqr-pow5.3%
difference-of-squares5.3%
*-commutative5.3%
rem-cube-cbrt5.4%
metadata-eval5.4%
metadata-eval5.4%
+-commutative5.4%
metadata-eval5.4%
rem-cube-cbrt5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 48.0%
unpow1/351.0%
unpow251.0%
Simplified51.0%
Taylor expanded in x around 0 51.0%
unpow251.0%
associate-/r*52.6%
*-lft-identity52.6%
associate-*l/52.6%
unpow-152.6%
unpow-152.6%
pow-sqr52.6%
metadata-eval52.6%
Simplified52.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
unpow299.8%
associate-*r*99.8%
distribute-rgt-out99.8%
Simplified99.8%
Final simplification74.4%
(FPCore (x)
:precision binary64
(if (or (<= x -1.0) (not (<= x 1.0)))
(/ 0.3333333333333333 (pow (cbrt x) 2.0))
(-
(+ 1.0 (* x (+ 0.3333333333333333 (* x -0.1111111111111111))))
(cbrt x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 / pow(cbrt(x), 2.0);
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 / Math.pow(Math.cbrt(x), 2.0);
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(0.3333333333333333 / (cbrt(x) ^ 2.0)); else tmp = Float64(Float64(1.0 + Float64(x * Float64(0.3333333333333333 + Float64(x * -0.1111111111111111)))) - 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[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * N[(0.3333333333333333 + N[(x * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{0.3333333333333333}{{\left(\sqrt[3]{x}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(0.3333333333333333 + x \cdot -0.1111111111111111\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.9%
pow1/33.9%
rem-cube-cbrt3.9%
sqr-pow3.9%
pow1/35.1%
sqr-pow5.3%
difference-of-squares5.3%
*-commutative5.3%
rem-cube-cbrt5.4%
metadata-eval5.4%
metadata-eval5.4%
+-commutative5.4%
metadata-eval5.4%
rem-cube-cbrt5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 48.0%
unpow1/351.0%
unpow251.0%
Simplified51.0%
cbrt-div51.1%
metadata-eval51.1%
cbrt-prod95.6%
un-div-inv95.6%
unpow295.6%
Applied egg-rr95.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
unpow299.8%
associate-*r*99.8%
distribute-rgt-out99.8%
Simplified99.8%
Final simplification97.5%
(FPCore (x)
:precision binary64
(if (or (<= x -1.0) (not (<= x 1.0)))
(* 0.3333333333333333 (cbrt (* (/ 1.0 x) (/ 1.0 x))))
(-
(+ 1.0 (* x (+ 0.3333333333333333 (* x -0.1111111111111111))))
(cbrt x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * cbrt(((1.0 / x) * (1.0 / x)));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - 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) * (1.0 / x)));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(0.3333333333333333 * cbrt(Float64(Float64(1.0 / x) * Float64(1.0 / x)))); else tmp = Float64(Float64(1.0 + Float64(x * Float64(0.3333333333333333 + Float64(x * -0.1111111111111111)))) - 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[(N[(1.0 / x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * N[(0.3333333333333333 + N[(x * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $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 \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(0.3333333333333333 + x \cdot -0.1111111111111111\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.9%
pow1/33.9%
rem-cube-cbrt3.9%
sqr-pow3.9%
pow1/35.1%
sqr-pow5.3%
difference-of-squares5.3%
*-commutative5.3%
rem-cube-cbrt5.4%
metadata-eval5.4%
metadata-eval5.4%
+-commutative5.4%
metadata-eval5.4%
rem-cube-cbrt5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 48.0%
unpow1/351.0%
unpow251.0%
Simplified51.0%
associate-/r*52.6%
div-inv52.6%
Applied egg-rr52.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
unpow299.8%
associate-*r*99.8%
distribute-rgt-out99.8%
Simplified99.8%
Final simplification74.3%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (* 0.3333333333333333 (cbrt (* (/ 1.0 x) (/ 1.0 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) * (1.0 / 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) * (1.0 / 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(Float64(1.0 / x) * Float64(1.0 / x)))); else tmp = Float64(Float64(1.0 + 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[(N[(1.0 / x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $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 \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot 0.3333333333333333\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.9%
pow1/33.9%
rem-cube-cbrt3.9%
sqr-pow3.9%
pow1/35.1%
sqr-pow5.3%
difference-of-squares5.3%
*-commutative5.3%
rem-cube-cbrt5.4%
metadata-eval5.4%
metadata-eval5.4%
+-commutative5.4%
metadata-eval5.4%
rem-cube-cbrt5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 48.0%
unpow1/351.0%
unpow251.0%
Simplified51.0%
associate-/r*52.6%
div-inv52.6%
Applied egg-rr52.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
unpow299.8%
associate-*r*99.8%
distribute-rgt-out99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Final simplification74.3%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ 0.3333333333333333 (cbrt (* 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((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((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(x * x))); else tmp = Float64(Float64(1.0 + 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[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{0.3333333333333333}{\sqrt[3]{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot 0.3333333333333333\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.9%
pow1/33.9%
rem-cube-cbrt3.9%
sqr-pow3.9%
pow1/35.1%
sqr-pow5.3%
difference-of-squares5.3%
*-commutative5.3%
rem-cube-cbrt5.4%
metadata-eval5.4%
metadata-eval5.4%
+-commutative5.4%
metadata-eval5.4%
rem-cube-cbrt5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 48.0%
unpow1/351.0%
unpow251.0%
Simplified51.0%
frac-2neg51.0%
metadata-eval51.0%
cbrt-div51.1%
distribute-rgt-neg-in51.1%
Applied egg-rr51.1%
clear-num51.1%
un-div-inv51.2%
cbrt-undiv51.2%
div-inv51.2%
distribute-rgt-neg-out51.2%
metadata-eval51.2%
Applied egg-rr51.2%
*-commutative51.2%
neg-mul-151.2%
associate-*r*51.2%
metadata-eval51.2%
associate-*l*51.2%
*-lft-identity51.2%
Simplified51.2%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
unpow299.8%
associate-*r*99.8%
distribute-rgt-out99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Final simplification73.5%
(FPCore (x) :precision binary64 (if (or (<= x -0.082) (not (<= x 0.26))) (/ 0.3333333333333333 (cbrt (* x x))) (+ 1.0 (* x -0.6666666666666666))))
double code(double x) {
double tmp;
if ((x <= -0.082) || !(x <= 0.26)) {
tmp = 0.3333333333333333 / cbrt((x * x));
} else {
tmp = 1.0 + (x * -0.6666666666666666);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.082) || !(x <= 0.26)) {
tmp = 0.3333333333333333 / Math.cbrt((x * x));
} else {
tmp = 1.0 + (x * -0.6666666666666666);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.082) || !(x <= 0.26)) tmp = Float64(0.3333333333333333 / cbrt(Float64(x * x))); else tmp = Float64(1.0 + Float64(x * -0.6666666666666666)); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.082], N[Not[LessEqual[x, 0.26]], $MachinePrecision]], N[(0.3333333333333333 / N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.082 \lor \neg \left(x \leq 0.26\right):\\
\;\;\;\;\frac{0.3333333333333333}{\sqrt[3]{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot -0.6666666666666666\\
\end{array}
\end{array}
if x < -0.0820000000000000034 or 0.26000000000000001 < x Initial program 8.9%
pow1/33.9%
rem-cube-cbrt3.9%
sqr-pow3.9%
pow1/35.1%
sqr-pow5.3%
difference-of-squares5.3%
*-commutative5.3%
rem-cube-cbrt5.4%
metadata-eval5.4%
metadata-eval5.4%
+-commutative5.4%
metadata-eval5.4%
rem-cube-cbrt5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 48.0%
unpow1/351.0%
unpow251.0%
Simplified51.0%
frac-2neg51.0%
metadata-eval51.0%
cbrt-div51.1%
distribute-rgt-neg-in51.1%
Applied egg-rr51.1%
clear-num51.1%
un-div-inv51.2%
cbrt-undiv51.2%
div-inv51.2%
distribute-rgt-neg-out51.2%
metadata-eval51.2%
Applied egg-rr51.2%
*-commutative51.2%
neg-mul-151.2%
associate-*r*51.2%
metadata-eval51.2%
associate-*l*51.2%
*-lft-identity51.2%
Simplified51.2%
if -0.0820000000000000034 < x < 0.26000000000000001Initial program 100.0%
add-exp-log_binary64100.0%
Applied rewrite-once100.0%
flip3--99.9%
log-div99.9%
+-commutative99.9%
rem-cube-cbrt99.9%
rem-cube-cbrt99.9%
+-commutative99.9%
+-commutative99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 94.3%
*-commutative94.3%
Simplified94.3%
Final simplification71.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 50.8%
Taylor expanded in x around inf 3.7%
Final simplification3.7%
(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 50.8%
Taylor expanded in x around 0 47.0%
Final simplification47.0%
herbie shell --seed 2023297
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))