
(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))) (t_1 (pow t_0 2.0)))
(/
1.0
(+
t_1
(/ (cbrt x) (/ (fma (cbrt x) (- (cbrt x) t_0) t_1) (+ 1.0 (* x 2.0))))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = pow(t_0, 2.0);
return 1.0 / (t_1 + (cbrt(x) / (fma(cbrt(x), (cbrt(x) - t_0), t_1) / (1.0 + (x * 2.0)))));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = t_0 ^ 2.0 return Float64(1.0 / Float64(t_1 + Float64(cbrt(x) / Float64(fma(cbrt(x), Float64(cbrt(x) - t_0), t_1) / Float64(1.0 + Float64(x * 2.0)))))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, N[(1.0 / N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] / N[(N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] - t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision] / N[(1.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := {t_0}^{2}\\
\frac{1}{t_1 + \frac{\sqrt[3]{x}}{\frac{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} - t_0, t_1\right)}{1 + x \cdot 2}}}
\end{array}
\end{array}
Initial program 55.9%
pow1/327.4%
Applied egg-rr27.4%
pow1/355.9%
flip3--55.9%
div-inv55.9%
add-sqr-sqrt27.2%
cbrt-unprod27.1%
rem-cube-cbrt26.9%
cbrt-unprod27.1%
add-sqr-sqrt55.7%
rem-cube-cbrt56.9%
pow256.9%
distribute-rgt-out56.9%
Applied egg-rr56.9%
associate-*r/56.9%
*-rgt-identity56.9%
+-commutative56.9%
associate--l+99.2%
+-inverses99.2%
metadata-eval99.2%
+-inverses99.2%
sub-neg99.2%
+-commutative99.2%
*-rgt-identity99.2%
fma-udef99.2%
sub-neg99.2%
fma-udef99.2%
*-rgt-identity99.2%
+-commutative99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
fma-udef99.2%
+-commutative99.2%
distribute-rgt-in99.2%
+-commutative99.2%
distribute-rgt-in99.2%
+-commutative99.2%
Applied egg-rr99.2%
flip3-+99.3%
associate-*r/86.1%
rem-cube-cbrt86.2%
rem-cube-cbrt86.4%
+-commutative86.4%
+-commutative86.4%
pow1/369.1%
pow1/368.8%
pow-prod-up68.8%
metadata-eval68.8%
metadata-eval68.8%
pow-prod-up69.3%
pow1/269.3%
Applied egg-rr86.4%
associate-/l*99.7%
+-commutative99.7%
+-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
count-299.7%
Simplified99.7%
Final simplification99.7%
(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)))))
(- (* (cbrt (fma x x -1.0)) (cbrt (/ 1.0 (+ x -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 = (cbrt(fma(x, x, -1.0)) * cbrt((1.0 / (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)) <= 0.0) 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(1.0 / 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], 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[(N[Power[N[(x * x + -1.0), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / N[(x + -1.0), $MachinePrecision]), $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 0:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\mathsf{fma}\left(x, x, -1\right)} \cdot \sqrt[3]{\frac{1}{x + -1}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.3%
pow1/32.7%
Applied egg-rr2.7%
pow1/34.3%
flip3--4.3%
div-inv4.3%
add-sqr-sqrt2.3%
cbrt-unprod2.0%
rem-cube-cbrt1.7%
cbrt-unprod1.9%
add-sqr-sqrt3.8%
rem-cube-cbrt4.3%
pow24.3%
distribute-rgt-out4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+98.5%
+-inverses98.5%
metadata-eval98.5%
+-inverses98.5%
sub-neg98.5%
+-commutative98.5%
*-rgt-identity98.5%
fma-udef98.5%
sub-neg98.5%
fma-udef98.5%
*-rgt-identity98.5%
+-commutative98.5%
sub-neg98.5%
+-inverses98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
fma-udef98.5%
+-commutative98.5%
distribute-rgt-in98.5%
+-commutative98.5%
distribute-rgt-in98.5%
+-commutative98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.1%
pow1/396.5%
flip-+96.5%
div-inv96.5%
unpow-prod-down1.5%
metadata-eval1.5%
fma-neg1.5%
metadata-eval1.5%
sub-neg1.5%
metadata-eval1.5%
Applied egg-rr1.5%
unpow1/31.5%
unpow1/398.1%
Simplified98.1%
Final simplification63.0%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ t_0 (cbrt x)) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (t_0 + cbrt(x)), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(t_0 + cbrt(x)), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0 + \sqrt[3]{x}, {t_0}^{2}\right)}
\end{array}
\end{array}
Initial program 55.9%
pow1/327.4%
Applied egg-rr27.4%
pow1/355.9%
flip3--55.9%
div-inv55.9%
add-sqr-sqrt27.2%
cbrt-unprod27.1%
rem-cube-cbrt26.9%
cbrt-unprod27.1%
add-sqr-sqrt55.7%
rem-cube-cbrt56.9%
pow256.9%
distribute-rgt-out56.9%
Applied egg-rr56.9%
associate-*r/56.9%
*-rgt-identity56.9%
+-commutative56.9%
associate--l+99.2%
+-inverses99.2%
metadata-eval99.2%
+-inverses99.2%
sub-neg99.2%
+-commutative99.2%
*-rgt-identity99.2%
fma-udef99.2%
sub-neg99.2%
fma-udef99.2%
*-rgt-identity99.2%
+-commutative99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.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.8%
pow1/30.0%
Applied egg-rr0.0%
pow1/34.8%
flip3--4.8%
div-inv4.8%
add-sqr-sqrt0.0%
cbrt-unprod0.0%
rem-cube-cbrt0.0%
cbrt-unprod0.0%
add-sqr-sqrt3.6%
rem-cube-cbrt4.8%
pow24.8%
distribute-rgt-out4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+98.3%
+-inverses98.3%
metadata-eval98.3%
+-inverses98.3%
sub-neg98.3%
+-commutative98.3%
*-rgt-identity98.3%
fma-udef98.3%
sub-neg98.3%
fma-udef98.3%
*-rgt-identity98.3%
+-commutative98.3%
sub-neg98.3%
+-inverses98.3%
metadata-eval98.3%
+-commutative98.3%
Simplified98.4%
fma-udef98.3%
+-commutative98.3%
distribute-rgt-in98.3%
+-commutative98.3%
distribute-rgt-in98.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around 0 20.0%
if -1.35000000000000003e154 < x < 1.31999999999999998e154Initial program 74.1%
pow1/336.5%
Applied egg-rr36.5%
pow1/374.1%
flip3--74.0%
div-inv74.0%
add-sqr-sqrt36.1%
cbrt-unprod36.1%
rem-cube-cbrt36.0%
cbrt-unprod36.1%
add-sqr-sqrt74.3%
rem-cube-cbrt75.4%
pow275.4%
distribute-rgt-out75.4%
Applied egg-rr75.4%
associate-*r/75.4%
*-rgt-identity75.4%
+-commutative75.4%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-inverses99.5%
sub-neg99.5%
+-commutative99.5%
*-rgt-identity99.5%
fma-udef99.5%
sub-neg99.5%
fma-udef99.5%
*-rgt-identity99.5%
+-commutative99.5%
sub-neg99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
fma-udef99.5%
+-commutative99.5%
distribute-rgt-in99.5%
+-commutative99.5%
distribute-rgt-in99.5%
+-commutative99.5%
Applied egg-rr99.5%
unpow299.5%
cbrt-unprod99.6%
add-exp-log86.6%
log1p-udef86.6%
add-exp-log86.4%
log1p-udef86.4%
log1p-udef86.4%
add-exp-log86.6%
log1p-udef86.6%
add-exp-log99.6%
pow299.6%
Applied egg-rr99.6%
if 1.31999999999999998e154 < x Initial program 4.8%
pow1/33.9%
Applied egg-rr3.9%
pow1/34.8%
flip3--4.8%
div-inv4.8%
add-sqr-sqrt4.7%
cbrt-unprod3.6%
rem-cube-cbrt2.9%
cbrt-unprod3.5%
add-sqr-sqrt3.1%
rem-cube-cbrt4.8%
pow24.8%
distribute-rgt-out4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+98.7%
+-inverses98.7%
metadata-eval98.7%
+-inverses98.7%
sub-neg98.7%
+-commutative98.7%
*-rgt-identity98.7%
fma-udef98.7%
sub-neg98.7%
fma-udef98.7%
*-rgt-identity98.7%
+-commutative98.7%
sub-neg98.7%
+-inverses98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
fma-udef98.7%
+-commutative98.7%
distribute-rgt-in98.7%
+-commutative98.7%
distribute-rgt-in98.7%
+-commutative98.7%
Applied egg-rr98.7%
add-exp-log93.1%
log-pow93.1%
pow1/392.5%
log-pow92.6%
log1p-udef92.6%
Applied egg-rr92.6%
associate-*r*92.6%
metadata-eval92.6%
Simplified92.6%
Final simplification87.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)))))
(- (cbrt (/ (- 1.0 (pow x 2.0)) (- 1.0 x))) (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 = cbrt(((1.0 - pow(x, 2.0)) / (1.0 - x))) - 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.cbrt(((1.0 - Math.pow(x, 2.0)) / (1.0 - x))) - 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(cbrt(Float64(Float64(1.0 - (x ^ 2.0)) / Float64(1.0 - x))) - 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[Power[N[(N[(1.0 - N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], 1/3], $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}:\\
\;\;\;\;\sqrt[3]{\frac{1 - {x}^{2}}{1 - x}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.3%
pow1/32.7%
Applied egg-rr2.7%
pow1/34.3%
flip3--4.3%
div-inv4.3%
add-sqr-sqrt2.3%
cbrt-unprod2.0%
rem-cube-cbrt1.7%
cbrt-unprod1.9%
add-sqr-sqrt3.8%
rem-cube-cbrt4.3%
pow24.3%
distribute-rgt-out4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+98.5%
+-inverses98.5%
metadata-eval98.5%
+-inverses98.5%
sub-neg98.5%
+-commutative98.5%
*-rgt-identity98.5%
fma-udef98.5%
sub-neg98.5%
fma-udef98.5%
*-rgt-identity98.5%
+-commutative98.5%
sub-neg98.5%
+-inverses98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
fma-udef98.5%
+-commutative98.5%
distribute-rgt-in98.5%
+-commutative98.5%
distribute-rgt-in98.5%
+-commutative98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.1%
add-exp-log96.5%
pow1/396.6%
log-pow96.5%
+-commutative96.5%
log1p-udef96.5%
Applied egg-rr96.5%
*-commutative96.5%
exp-prod96.5%
unpow1/396.5%
Simplified96.5%
log1p-udef96.5%
add-exp-log98.1%
flip-+98.1%
metadata-eval98.1%
div-sub98.1%
pow298.1%
Applied egg-rr98.1%
div-sub98.1%
Simplified98.1%
Final simplification63.0%
(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 7.7%
pow1/30.0%
Applied egg-rr0.0%
pow1/37.7%
flip3--7.7%
div-inv7.7%
add-sqr-sqrt0.0%
cbrt-unprod0.0%
rem-cube-cbrt0.0%
cbrt-unprod0.0%
add-sqr-sqrt7.9%
rem-cube-cbrt9.1%
pow29.1%
distribute-rgt-out9.1%
Applied egg-rr9.1%
associate-*r/9.1%
*-rgt-identity9.1%
+-commutative9.1%
associate--l+98.4%
+-inverses98.4%
metadata-eval98.4%
+-inverses98.4%
sub-neg98.4%
+-commutative98.4%
*-rgt-identity98.4%
fma-udef98.4%
sub-neg98.4%
fma-udef98.4%
*-rgt-identity98.4%
+-commutative98.4%
sub-neg98.4%
+-inverses98.4%
metadata-eval98.4%
+-commutative98.4%
Simplified98.5%
fma-udef98.4%
+-commutative98.4%
distribute-rgt-in98.4%
+-commutative98.4%
distribute-rgt-in98.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 20.0%
if -1 < x Initial program 70.7%
pow1/335.8%
Applied egg-rr35.8%
pow1/370.7%
flip3--70.7%
div-inv70.7%
add-sqr-sqrt35.6%
cbrt-unprod35.3%
rem-cube-cbrt35.2%
cbrt-unprod35.4%
add-sqr-sqrt70.4%
rem-cube-cbrt71.5%
pow271.5%
distribute-rgt-out71.5%
Applied egg-rr71.5%
associate-*r/71.5%
*-rgt-identity71.5%
+-commutative71.5%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-inverses99.5%
sub-neg99.5%
+-commutative99.5%
*-rgt-identity99.5%
fma-udef99.5%
sub-neg99.5%
fma-udef99.5%
*-rgt-identity99.5%
+-commutative99.5%
sub-neg99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
fma-udef99.5%
+-commutative99.5%
distribute-rgt-in99.5%
+-commutative99.5%
distribute-rgt-in99.5%
+-commutative99.5%
Applied egg-rr99.5%
add-exp-log98.1%
log-pow98.1%
pow1/397.9%
log-pow97.9%
log1p-udef97.9%
Applied egg-rr97.9%
associate-*r*97.9%
metadata-eval97.9%
Simplified97.9%
Final simplification79.6%
(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 7.7%
pow1/30.0%
Applied egg-rr0.0%
pow1/37.7%
flip3--7.7%
div-inv7.7%
add-sqr-sqrt0.0%
cbrt-unprod0.0%
rem-cube-cbrt0.0%
cbrt-unprod0.0%
add-sqr-sqrt7.9%
rem-cube-cbrt9.1%
pow29.1%
distribute-rgt-out9.1%
Applied egg-rr9.1%
associate-*r/9.1%
*-rgt-identity9.1%
+-commutative9.1%
associate--l+98.4%
+-inverses98.4%
metadata-eval98.4%
+-inverses98.4%
sub-neg98.4%
+-commutative98.4%
*-rgt-identity98.4%
fma-udef98.4%
sub-neg98.4%
fma-udef98.4%
*-rgt-identity98.4%
+-commutative98.4%
sub-neg98.4%
+-inverses98.4%
metadata-eval98.4%
+-commutative98.4%
Simplified98.5%
fma-udef98.4%
+-commutative98.4%
distribute-rgt-in98.4%
+-commutative98.4%
distribute-rgt-in98.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 20.0%
if -1 < x Initial program 70.7%
pow1/335.8%
Applied egg-rr35.8%
pow1/370.7%
flip3--70.7%
div-inv70.7%
add-sqr-sqrt35.6%
cbrt-unprod35.3%
rem-cube-cbrt35.2%
cbrt-unprod35.4%
add-sqr-sqrt70.4%
rem-cube-cbrt71.5%
pow271.5%
distribute-rgt-out71.5%
Applied egg-rr71.5%
associate-*r/71.5%
*-rgt-identity71.5%
+-commutative71.5%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-inverses99.5%
sub-neg99.5%
+-commutative99.5%
*-rgt-identity99.5%
fma-udef99.5%
sub-neg99.5%
fma-udef99.5%
*-rgt-identity99.5%
+-commutative99.5%
sub-neg99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
unpow299.5%
add-sqr-sqrt99.4%
associate-*r*99.4%
add-sqr-sqrt99.4%
sqrt-prod99.4%
unpow299.4%
sqrt-prod99.4%
unpow299.4%
add-cube-cbrt99.6%
add-exp-log98.2%
log1p-udef98.2%
log1p-udef98.2%
add-exp-log99.6%
add-sqr-sqrt64.4%
hypot-1-def64.4%
pow1/363.4%
sqrt-pow163.4%
Applied egg-rr63.4%
*-commutative63.4%
hypot-1-def63.4%
rem-square-sqrt98.6%
Simplified98.6%
pow1/298.6%
pow-prod-up97.7%
+-commutative97.7%
metadata-eval97.7%
Applied egg-rr97.7%
Final simplification79.5%
(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 55.9%
pow1/327.4%
Applied egg-rr27.4%
pow1/355.9%
flip3--55.9%
div-inv55.9%
add-sqr-sqrt27.2%
cbrt-unprod27.1%
rem-cube-cbrt26.9%
cbrt-unprod27.1%
add-sqr-sqrt55.7%
rem-cube-cbrt56.9%
pow256.9%
distribute-rgt-out56.9%
Applied egg-rr56.9%
associate-*r/56.9%
*-rgt-identity56.9%
+-commutative56.9%
associate--l+99.2%
+-inverses99.2%
metadata-eval99.2%
+-inverses99.2%
sub-neg99.2%
+-commutative99.2%
*-rgt-identity99.2%
fma-udef99.2%
sub-neg99.2%
fma-udef99.2%
*-rgt-identity99.2%
+-commutative99.2%
sub-neg99.2%
+-inverses99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
fma-udef99.2%
+-commutative99.2%
distribute-rgt-in99.2%
+-commutative99.2%
distribute-rgt-in99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification99.2%
(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 55.9%
Final simplification55.9%
(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 55.9%
add-cube-cbrt55.7%
pow355.7%
Applied egg-rr55.7%
Taylor expanded in x around 0 26.2%
associate--l+26.2%
*-commutative26.2%
metadata-eval26.2%
pow-base-126.2%
unpow1/353.3%
*-lft-identity53.3%
Simplified53.3%
Final simplification53.3%
(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.9%
add-cube-cbrt55.7%
pow355.7%
Applied egg-rr55.7%
Taylor expanded in x around 0 24.9%
metadata-eval24.9%
pow-base-124.9%
unpow1/352.4%
*-lft-identity52.4%
Simplified52.4%
Final simplification52.4%
(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.9%
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.9%
Taylor expanded in x around 0 51.0%
Final simplification51.0%
herbie shell --seed 2024021
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))