
(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 13 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 53.8%
flip3--53.8%
div-inv53.8%
rem-cube-cbrt53.7%
rem-cube-cbrt55.3%
cbrt-unprod55.3%
pow255.3%
distribute-rgt-out55.3%
+-commutative55.3%
Applied egg-rr55.3%
associate-*r/55.3%
*-rgt-identity55.3%
+-commutative55.3%
associate--l+78.4%
+-inverses78.4%
metadata-eval78.4%
+-commutative78.4%
fma-def78.4%
+-commutative78.4%
+-commutative78.4%
Simplified78.4%
fma-udef78.4%
pow1/377.2%
unpow277.2%
pow-prod-down72.9%
+-commutative72.9%
pow1/373.3%
+-commutative73.3%
pow1/399.1%
+-commutative99.1%
pow299.1%
+-commutative99.1%
pow1/347.2%
metadata-eval47.2%
pow-pow47.2%
*-commutative47.2%
pow-pow47.2%
metadata-eval47.2%
pow1/399.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (+ 1.0 (* (cbrt x) (+ t_0 (cbrt x)))))
(log (exp (- (+ 1.0 (+ t_0 -1.0)) (cbrt x)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / (1.0 + (cbrt(x) * (t_0 + cbrt(x))));
} else {
tmp = log(exp(((1.0 + (t_0 + -1.0)) - cbrt(x))));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (t_0 + Math.cbrt(x))));
} else {
tmp = Math.log(Math.exp(((1.0 + (t_0 + -1.0)) - Math.cbrt(x))));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(t_0 + cbrt(x))))); else tmp = log(exp(Float64(Float64(1.0 + Float64(t_0 + -1.0)) - cbrt(x)))); end return tmp end
code[x_] := Block[{t$95$0 = 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[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[N[(N[(1.0 + N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\left(1 + \left(t_0 + -1\right)\right) - \sqrt[3]{x}}\right)\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.1%
flip3--4.1%
div-inv4.1%
rem-cube-cbrt4.0%
rem-cube-cbrt4.9%
cbrt-unprod4.9%
pow24.9%
distribute-rgt-out4.9%
+-commutative4.9%
Applied egg-rr4.9%
associate-*r/4.9%
*-rgt-identity4.9%
+-commutative4.9%
associate--l+54.1%
+-inverses54.1%
metadata-eval54.1%
+-commutative54.1%
fma-def54.1%
+-commutative54.1%
+-commutative54.1%
Simplified54.1%
fma-udef54.1%
pow1/351.6%
unpow251.6%
pow-prod-down46.6%
+-commutative46.6%
pow1/347.3%
+-commutative47.3%
pow1/398.4%
+-commutative98.4%
pow298.4%
+-commutative98.4%
pow1/346.6%
metadata-eval46.6%
pow-pow46.6%
*-commutative46.6%
pow-pow46.6%
metadata-eval46.6%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.6%
add-log-exp97.6%
Applied egg-rr97.6%
expm1-log1p-u95.4%
expm1-udef95.4%
log1p-udef95.4%
add-exp-log97.6%
Applied egg-rr97.6%
associate--l+97.6%
+-commutative97.6%
Simplified97.6%
Final simplification61.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (+ 1.0 (* (cbrt x) (+ t_0 (cbrt x)))))
(- (/ (cbrt (fma x x -1.0)) (cbrt (+ x -1.0))) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / (1.0 + (cbrt(x) * (t_0 + cbrt(x))));
} else {
tmp = (cbrt(fma(x, x, -1.0)) / cbrt((x + -1.0))) - cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(t_0 + cbrt(x))))); else tmp = Float64(Float64(cbrt(fma(x, x, -1.0)) / cbrt(Float64(x + -1.0))) - cbrt(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-11], 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], N[(N[(N[Power[N[(x * x + -1.0), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(x + -1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(x, x, -1\right)}}{\sqrt[3]{x + -1}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt4.1%
rem-cube-cbrt5.7%
cbrt-unprod5.7%
pow25.7%
distribute-rgt-out5.7%
+-commutative5.7%
Applied egg-rr5.7%
associate-*r/5.7%
*-rgt-identity5.7%
+-commutative5.7%
associate--l+54.4%
+-inverses54.4%
metadata-eval54.4%
+-commutative54.4%
fma-def54.4%
+-commutative54.4%
+-commutative54.4%
Simplified54.4%
fma-udef54.4%
pow1/352.0%
unpow252.0%
pow-prod-down47.0%
+-commutative47.0%
pow1/347.7%
+-commutative47.7%
pow1/398.4%
+-commutative98.4%
pow298.4%
+-commutative98.4%
pow1/347.0%
metadata-eval47.0%
pow-pow47.0%
*-commutative47.0%
pow-pow47.0%
metadata-eval47.0%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 20.0%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.1%
flip-+98.1%
cbrt-div98.2%
metadata-eval98.2%
fma-neg98.2%
metadata-eval98.2%
sub-neg98.2%
metadata-eval98.2%
Applied egg-rr98.2%
Final simplification61.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.35e+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.35e+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.35e+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.35e+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.35e+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.35 \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%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.4%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
fma-udef4.7%
pow1/34.7%
unpow24.7%
pow-prod-down0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/397.9%
+-commutative97.9%
pow297.9%
+-commutative97.9%
pow1/30.0%
metadata-eval0.0%
pow-pow0.0%
*-commutative0.0%
pow-pow0.0%
metadata-eval0.0%
pow1/397.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 20.0%
if -1.35000000000000003e154 < x < 1.35000000000000003e154Initial program 67.8%
flip3--67.8%
div-inv67.8%
rem-cube-cbrt68.2%
rem-cube-cbrt69.8%
cbrt-unprod69.8%
pow269.8%
distribute-rgt-out69.8%
+-commutative69.8%
Applied egg-rr69.8%
associate-*r/69.8%
*-rgt-identity69.8%
+-commutative69.8%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
fma-def99.5%
+-commutative99.5%
+-commutative99.5%
Simplified99.5%
fma-udef99.5%
pow1/398.0%
unpow298.0%
pow-prod-down82.8%
+-commutative82.8%
pow1/383.0%
+-commutative83.0%
pow1/399.4%
+-commutative99.4%
pow299.4%
+-commutative99.4%
pow1/349.6%
metadata-eval49.6%
pow-pow49.6%
*-commutative49.6%
pow-pow49.6%
metadata-eval49.6%
pow1/399.4%
Applied egg-rr99.4%
unpow299.4%
cbrt-unprod99.5%
pow299.5%
Applied egg-rr99.5%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt2.8%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
fma-udef4.7%
pow1/34.7%
unpow24.7%
pow-prod-down91.7%
+-commutative91.7%
pow1/393.2%
+-commutative93.2%
pow1/398.8%
+-commutative98.8%
pow298.8%
+-commutative98.8%
pow1/391.7%
metadata-eval91.7%
pow-pow91.7%
*-commutative91.7%
pow-pow91.7%
metadata-eval91.7%
pow1/398.8%
Applied egg-rr98.8%
add-exp-log93.0%
+-commutative93.0%
log-pow93.0%
pow1/392.4%
+-commutative92.4%
metadata-eval92.4%
log-pow91.7%
metadata-eval91.7%
log1p-udef91.7%
Applied egg-rr91.7%
associate-*r*91.7%
metadata-eval91.7%
Simplified91.7%
Final simplification88.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (+ 1.0 (* (cbrt x) (+ t_0 (cbrt x)))))
(- (+ 1.0 (+ t_0 -1.0)) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / (1.0 + (cbrt(x) * (t_0 + cbrt(x))));
} else {
tmp = (1.0 + (t_0 + -1.0)) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (t_0 + Math.cbrt(x))));
} else {
tmp = (1.0 + (t_0 + -1.0)) - Math.cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(t_0 + cbrt(x))))); else tmp = Float64(Float64(1.0 + Float64(t_0 + -1.0)) - cbrt(x)); end return tmp end
code[x_] := Block[{t$95$0 = 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[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(t_0 + -1\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.1%
flip3--4.1%
div-inv4.1%
rem-cube-cbrt4.0%
rem-cube-cbrt4.9%
cbrt-unprod4.9%
pow24.9%
distribute-rgt-out4.9%
+-commutative4.9%
Applied egg-rr4.9%
associate-*r/4.9%
*-rgt-identity4.9%
+-commutative4.9%
associate--l+54.1%
+-inverses54.1%
metadata-eval54.1%
+-commutative54.1%
fma-def54.1%
+-commutative54.1%
+-commutative54.1%
Simplified54.1%
fma-udef54.1%
pow1/351.6%
unpow251.6%
pow-prod-down46.6%
+-commutative46.6%
pow1/347.3%
+-commutative47.3%
pow1/398.4%
+-commutative98.4%
pow298.4%
+-commutative98.4%
pow1/346.6%
metadata-eval46.6%
pow-pow46.6%
*-commutative46.6%
pow-pow46.6%
metadata-eval46.6%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.6%
expm1-log1p-u95.4%
expm1-udef95.4%
log1p-udef95.4%
add-exp-log97.6%
Applied egg-rr97.6%
associate--l+97.6%
+-commutative97.6%
Simplified97.6%
Final simplification61.2%
(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 8.1%
flip3--8.1%
div-inv8.1%
rem-cube-cbrt8.2%
rem-cube-cbrt13.0%
cbrt-unprod13.0%
pow213.0%
distribute-rgt-out13.0%
+-commutative13.0%
Applied egg-rr13.0%
associate-*r/13.0%
*-rgt-identity13.0%
+-commutative13.0%
associate--l+51.0%
+-inverses51.0%
metadata-eval51.0%
+-commutative51.0%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
fma-udef51.0%
pow1/349.0%
unpow249.0%
pow-prod-down0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/398.1%
+-commutative98.1%
pow298.1%
+-commutative98.1%
pow1/30.0%
metadata-eval0.0%
pow-pow0.0%
*-commutative0.0%
pow-pow0.0%
metadata-eval0.0%
pow1/398.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 20.0%
if -1 < x Initial program 69.3%
flip3--69.3%
div-inv69.3%
rem-cube-cbrt69.2%
rem-cube-cbrt69.7%
cbrt-unprod69.7%
pow269.7%
distribute-rgt-out69.7%
+-commutative69.7%
Applied egg-rr69.7%
associate-*r/69.7%
*-rgt-identity69.7%
+-commutative69.7%
associate--l+87.7%
+-inverses87.7%
metadata-eval87.7%
+-commutative87.7%
fma-def87.7%
+-commutative87.7%
+-commutative87.7%
Simplified87.7%
fma-udef87.7%
pow1/386.8%
unpow286.8%
pow-prod-down97.8%
+-commutative97.8%
pow1/398.2%
+-commutative98.2%
pow1/399.5%
+-commutative99.5%
pow299.5%
+-commutative99.5%
pow1/363.2%
metadata-eval63.2%
pow-pow63.2%
*-commutative63.2%
pow-pow63.2%
metadata-eval63.2%
pow1/399.5%
Applied egg-rr99.5%
add-exp-log98.1%
+-commutative98.1%
log-pow98.1%
pow1/397.9%
+-commutative97.9%
metadata-eval97.9%
log-pow97.8%
metadata-eval97.8%
log1p-udef97.8%
Applied egg-rr97.8%
associate-*r*97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification78.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= x -1.0)
(/ 1.0 (+ 1.0 (* (cbrt x) t_0)))
(/ 1.0 (fma (cbrt x) t_0 (pow (+ 1.0 x) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt((1.0 + x)) + cbrt(x);
double tmp;
if (x <= -1.0) {
tmp = 1.0 / (1.0 + (cbrt(x) * t_0));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) + cbrt(x)) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * t_0))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, (Float64(1.0 + x) ^ 0.6666666666666666))); 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[x, -1.0], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} + \sqrt[3]{x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1Initial program 8.1%
flip3--8.1%
div-inv8.1%
rem-cube-cbrt8.2%
rem-cube-cbrt13.0%
cbrt-unprod13.0%
pow213.0%
distribute-rgt-out13.0%
+-commutative13.0%
Applied egg-rr13.0%
associate-*r/13.0%
*-rgt-identity13.0%
+-commutative13.0%
associate--l+51.0%
+-inverses51.0%
metadata-eval51.0%
+-commutative51.0%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
fma-udef51.0%
pow1/349.0%
unpow249.0%
pow-prod-down0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/398.1%
+-commutative98.1%
pow298.1%
+-commutative98.1%
pow1/30.0%
metadata-eval0.0%
pow-pow0.0%
*-commutative0.0%
pow-pow0.0%
metadata-eval0.0%
pow1/398.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 20.0%
if -1 < x Initial program 69.3%
flip3--69.3%
div-inv69.3%
rem-cube-cbrt69.2%
rem-cube-cbrt69.7%
cbrt-unprod69.7%
pow269.7%
distribute-rgt-out69.7%
+-commutative69.7%
Applied egg-rr69.7%
associate-*r/69.7%
*-rgt-identity69.7%
+-commutative69.7%
associate--l+87.7%
+-inverses87.7%
metadata-eval87.7%
+-commutative87.7%
fma-def87.7%
+-commutative87.7%
+-commutative87.7%
Simplified87.7%
pow1/386.8%
pow-pow97.8%
metadata-eval97.8%
Applied egg-rr97.8%
Final simplification78.0%
(FPCore (x) :precision binary64 (- (+ 1.0 (+ (cbrt (+ 1.0 x)) -1.0)) (cbrt x)))
double code(double x) {
return (1.0 + (cbrt((1.0 + x)) + -1.0)) - cbrt(x);
}
public static double code(double x) {
return (1.0 + (Math.cbrt((1.0 + x)) + -1.0)) - Math.cbrt(x);
}
function code(x) return Float64(Float64(1.0 + Float64(cbrt(Float64(1.0 + x)) + -1.0)) - cbrt(x)) end
code[x_] := N[(N[(1.0 + N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + \left(\sqrt[3]{1 + x} + -1\right)\right) - \sqrt[3]{x}
\end{array}
Initial program 53.8%
expm1-log1p-u51.6%
expm1-udef51.6%
log1p-udef51.6%
add-exp-log53.8%
Applied egg-rr53.8%
associate--l+53.8%
+-commutative53.8%
Simplified53.8%
Final simplification53.8%
(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 53.8%
Final simplification53.8%
(FPCore (x) :precision binary64 (+ 1.0 (- (* x 0.3333333333333333) (cbrt x))))
double code(double x) {
return 1.0 + ((x * 0.3333333333333333) - cbrt(x));
}
public static double code(double x) {
return 1.0 + ((x * 0.3333333333333333) - Math.cbrt(x));
}
function code(x) return Float64(1.0 + Float64(Float64(x * 0.3333333333333333) - cbrt(x))) end
code[x_] := N[(1.0 + N[(N[(x * 0.3333333333333333), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right)
\end{array}
Initial program 53.8%
add-sqr-sqrt25.9%
pow225.9%
pow1/326.4%
sqrt-pow126.4%
metadata-eval26.4%
Applied egg-rr26.4%
Taylor expanded in x around 0 25.3%
unpow1/351.1%
*-lft-identity51.1%
pow-base-151.1%
metadata-eval51.1%
unpow1/325.3%
associate--l+25.4%
*-commutative25.4%
metadata-eval25.4%
pow-base-125.4%
unpow1/351.1%
*-lft-identity51.1%
Simplified51.1%
Final simplification51.1%
(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 53.8%
add-sqr-sqrt25.9%
pow225.9%
pow1/326.4%
sqrt-pow126.4%
metadata-eval26.4%
Applied egg-rr26.4%
Taylor expanded in x around 0 24.4%
unpow1/350.9%
Simplified50.9%
Final simplification50.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 53.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 53.8%
Taylor expanded in x around 0 49.5%
Final simplification49.5%
herbie shell --seed 2023218
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))