
(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 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0)))
(/ 1.0 (fma (cbrt x) t_1 (cbrt (pow (+ 1.0 x) 2.0)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) + t_0;
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, cbrt(pow((1.0 + x), 2.0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), t_1, (cbrt(x) ^ 2.0))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, cbrt((Float64(1.0 + x) ^ 2.0)))); 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[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} + t_0\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_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.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt4.3%
+-commutative4.3%
distribute-rgt-out4.3%
+-commutative4.3%
fma-def4.3%
add-exp-log4.3%
Applied egg-rr2.2%
associate-*r/2.2%
*-rgt-identity2.2%
+-commutative2.2%
associate--l+49.9%
+-inverses49.9%
metadata-eval49.9%
+-commutative49.9%
exp-prod49.4%
Simplified49.4%
metadata-eval49.4%
prod-exp49.4%
pow-prod-down50.1%
pow250.1%
pow-exp49.9%
*-commutative49.9%
log1p-udef49.9%
+-commutative49.9%
pow-to-exp49.8%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
unpow298.4%
+-commutative98.4%
Simplified98.4%
+-commutative98.4%
add-cube-cbrt98.0%
pow398.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 49.8%
unpow1/398.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
flip3--98.1%
div-inv98.1%
rem-cube-cbrt98.4%
rem-cube-cbrt99.8%
+-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
fma-def99.8%
add-exp-log99.8%
Applied egg-rr98.3%
associate-*r/98.3%
*-rgt-identity98.3%
+-commutative98.3%
associate--l+98.3%
+-inverses98.3%
metadata-eval98.3%
+-commutative98.3%
exp-prod98.3%
Simplified98.3%
metadata-eval98.3%
prod-exp98.3%
pow-prod-down98.3%
pow298.3%
pow-exp98.3%
*-commutative98.3%
log1p-udef98.3%
+-commutative98.3%
pow-to-exp98.3%
pow1/399.8%
pow299.8%
cbrt-unprod99.9%
pow299.9%
Applied egg-rr99.9%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 4e-6)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow (cbrt x) 2.0)))
(-
(* (cbrt (+ 1.0 (pow x 3.0))) (cbrt (/ 1.0 (- (fma x x 1.0) x))))
(cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 4e-6) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(cbrt(x), 2.0));
} else {
tmp = (cbrt((1.0 + pow(x, 3.0))) * cbrt((1.0 / (fma(x, x, 1.0) - x)))) - cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 4e-6) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (cbrt(x) ^ 2.0))); else tmp = Float64(Float64(cbrt(Float64(1.0 + (x ^ 3.0))) * cbrt(Float64(1.0 / Float64(fma(x, x, 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], 4e-6], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(1.0 + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / N[(N[(x * x + 1.0), $MachinePrecision] - x), $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 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{1 + {x}^{3}} \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(x, x, 1\right) - x}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 5.0%
flip3--5.0%
div-inv5.0%
rem-cube-cbrt4.7%
rem-cube-cbrt6.5%
+-commutative6.5%
distribute-rgt-out6.5%
+-commutative6.5%
fma-def6.5%
add-exp-log6.5%
Applied egg-rr4.5%
associate-*r/4.5%
*-rgt-identity4.5%
+-commutative4.5%
associate--l+51.0%
+-inverses51.0%
metadata-eval51.0%
+-commutative51.0%
exp-prod50.5%
Simplified50.5%
metadata-eval50.5%
prod-exp50.5%
pow-prod-down51.3%
pow251.3%
pow-exp51.0%
*-commutative51.0%
log1p-udef51.0%
+-commutative51.0%
pow-to-exp50.9%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
unpow298.4%
+-commutative98.4%
Simplified98.4%
+-commutative98.4%
add-cube-cbrt98.0%
pow398.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 50.5%
unpow1/398.0%
Simplified98.0%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
pow1/398.4%
flip3-+98.4%
div-inv98.4%
unpow-prod-down98.4%
pow398.4%
metadata-eval98.4%
+-commutative98.4%
pow398.4%
metadata-eval98.4%
*-rgt-identity98.4%
associate-+r-98.4%
fma-def98.4%
Applied egg-rr98.4%
unpow1/399.6%
unpow1/399.6%
Simplified99.6%
Final simplification98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 4e-6)
(/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) (+ (cbrt x) t_0))))
(-
(* (cbrt (+ 1.0 (pow x 3.0))) (cbrt (/ 1.0 (- (fma x x 1.0) x))))
(cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 4e-6) {
tmp = 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = (cbrt((1.0 + pow(x, 3.0))) * cbrt((1.0 / (fma(x, x, 1.0) - x)))) - cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 4e-6) tmp = Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); else tmp = Float64(Float64(cbrt(Float64(1.0 + (x ^ 3.0))) * cbrt(Float64(1.0 / Float64(fma(x, x, 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], 4e-6], N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(1.0 + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / N[(N[(x * x + 1.0), $MachinePrecision] - x), $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 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{1 + {x}^{3}} \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(x, x, 1\right) - x}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 5.0%
flip3--5.0%
div-inv5.0%
rem-cube-cbrt4.7%
rem-cube-cbrt6.5%
+-commutative6.5%
distribute-rgt-out6.5%
+-commutative6.5%
fma-def6.5%
add-exp-log6.5%
Applied egg-rr4.5%
associate-*r/4.5%
*-rgt-identity4.5%
+-commutative4.5%
associate--l+51.0%
+-inverses51.0%
metadata-eval51.0%
+-commutative51.0%
exp-prod50.5%
Simplified50.5%
Taylor expanded in x around inf 46.8%
unpow1/349.2%
Simplified49.2%
fma-udef49.2%
+-commutative49.2%
unpow249.2%
cbrt-prod98.0%
pow298.0%
+-commutative98.0%
+-commutative98.0%
Applied egg-rr98.0%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
pow1/398.4%
flip3-+98.4%
div-inv98.4%
unpow-prod-down98.4%
pow398.4%
metadata-eval98.4%
+-commutative98.4%
pow398.4%
metadata-eval98.4%
*-rgt-identity98.4%
associate-+r-98.4%
fma-def98.4%
Applied egg-rr98.4%
unpow1/399.6%
unpow1/399.6%
Simplified99.6%
Final simplification98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x))))
(if (<= t_1 4e-6)
(/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) (+ (cbrt x) t_0))))
t_1)))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 4e-6) {
tmp = 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 4e-6) {
tmp = 1.0 / (Math.pow(Math.cbrt(x), 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 4e-6) tmp = Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); 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[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e-6], N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 5.0%
flip3--5.0%
div-inv5.0%
rem-cube-cbrt4.7%
rem-cube-cbrt6.5%
+-commutative6.5%
distribute-rgt-out6.5%
+-commutative6.5%
fma-def6.5%
add-exp-log6.5%
Applied egg-rr4.5%
associate-*r/4.5%
*-rgt-identity4.5%
+-commutative4.5%
associate--l+51.0%
+-inverses51.0%
metadata-eval51.0%
+-commutative51.0%
exp-prod50.5%
Simplified50.5%
Taylor expanded in x around inf 46.8%
unpow1/349.2%
Simplified49.2%
fma-udef49.2%
+-commutative49.2%
unpow249.2%
cbrt-prod98.0%
pow298.0%
+-commutative98.0%
+-commutative98.0%
Applied egg-rr98.0%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
Final simplification98.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x)))) (if (<= t_1 4e-6) (/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) t_0)))) t_1)))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 4e-6) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 4e-6) {
tmp = 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 4e-6) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + t_0)))); 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[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e-6], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + t_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 5.0%
flip3--5.0%
div-inv5.0%
rem-cube-cbrt4.7%
rem-cube-cbrt6.5%
+-commutative6.5%
distribute-rgt-out6.5%
+-commutative6.5%
fma-def6.5%
add-exp-log6.5%
Applied egg-rr4.5%
associate-*r/4.5%
*-rgt-identity4.5%
+-commutative4.5%
associate--l+51.0%
+-inverses51.0%
metadata-eval51.0%
+-commutative51.0%
exp-prod50.5%
Simplified50.5%
Taylor expanded in x around inf 46.8%
unpow1/349.2%
Simplified49.2%
expm1-log1p-u49.2%
expm1-udef5.5%
+-commutative5.5%
+-commutative5.5%
unpow25.5%
cbrt-prod5.5%
pow25.5%
Applied egg-rr5.5%
expm1-def98.0%
expm1-log1p98.0%
fma-def98.0%
+-commutative98.0%
unpow298.0%
distribute-lft-out98.0%
+-commutative98.0%
Simplified98.0%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
Final simplification98.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) 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[(1.0 + x), $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]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {t_0}^{2}\right)}
\end{array}
\end{array}
Initial program 53.1%
flip3--53.0%
div-inv53.0%
rem-cube-cbrt53.0%
rem-cube-cbrt53.9%
+-commutative53.9%
distribute-rgt-out53.9%
+-commutative53.9%
fma-def53.9%
add-exp-log53.9%
Applied egg-rr52.1%
associate-*r/52.1%
*-rgt-identity52.1%
+-commutative52.1%
associate--l+75.1%
+-inverses75.1%
metadata-eval75.1%
+-commutative75.1%
exp-prod74.8%
Simplified74.8%
metadata-eval74.8%
prod-exp74.8%
pow-prod-down75.2%
pow275.2%
pow-exp75.1%
*-commutative75.1%
log1p-udef75.1%
+-commutative75.1%
pow-to-exp75.0%
pow1/399.1%
pow299.1%
Applied egg-rr99.1%
unpow299.1%
+-commutative99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x)))) (if (<= t_1 1e-10) (/ 1.0 (+ 1.0 (* (cbrt x) (+ (cbrt x) t_0)))) t_1)))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 1e-10) {
tmp = 1.0 / (1.0 + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 1e-10) {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 1e-10) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); 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[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-10], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 10^{-10}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000004e-10Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt4.0%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-def5.0%
add-exp-log5.0%
Applied egg-rr3.0%
associate-*r/3.0%
*-rgt-identity3.0%
+-commutative3.0%
associate--l+50.3%
+-inverses50.3%
metadata-eval50.3%
+-commutative50.3%
exp-prod49.8%
Simplified49.8%
Taylor expanded in x around 0 20.0%
fma-udef20.0%
+-commutative20.0%
Applied egg-rr20.0%
if 1.00000000000000004e-10 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.8%
Final simplification60.6%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 1e-10) (cbrt (/ 1.0 (pow x 2.0))) 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 / pow(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 <= 1e-10) {
tmp = Math.cbrt((1.0 / Math.pow(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 <= 1e-10) tmp = cbrt(Float64(1.0 / (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, 1e-10], N[Power[N[(1.0 / N[Power[x, 2.0], $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}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000004e-10Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt4.0%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-def5.0%
add-exp-log5.0%
Applied egg-rr3.0%
associate-*r/3.0%
*-rgt-identity3.0%
+-commutative3.0%
associate--l+50.3%
+-inverses50.3%
metadata-eval50.3%
+-commutative50.3%
exp-prod49.8%
Simplified49.8%
metadata-eval49.8%
prod-exp49.8%
pow-prod-down50.5%
pow250.5%
pow-exp50.3%
*-commutative50.3%
log1p-udef50.3%
+-commutative50.3%
pow-to-exp50.2%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
unpow298.4%
+-commutative98.4%
Simplified98.4%
+-commutative98.4%
add-cube-cbrt98.0%
pow398.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 10.8%
unpow1/310.8%
Simplified10.8%
if 1.00000000000000004e-10 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.8%
Final simplification56.2%
(FPCore (x) :precision binary64 (if (or (<= x -0.95) (not (<= x 2.7))) (cbrt (/ 1.0 (pow x 2.0))) (+ 1.0 (- (* x 0.3333333333333333) (cbrt x)))))
double code(double x) {
double tmp;
if ((x <= -0.95) || !(x <= 2.7)) {
tmp = cbrt((1.0 / pow(x, 2.0)));
} 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 / Math.pow(x, 2.0)));
} 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 / (x ^ 2.0))); 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[Power[x, 2.0], $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}^{2}}}\\
\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 6.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt6.8%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-def8.7%
add-exp-log8.7%
Applied egg-rr5.1%
associate-*r/5.1%
*-rgt-identity5.1%
+-commutative5.1%
associate--l+50.6%
+-inverses50.6%
metadata-eval50.6%
+-commutative50.6%
exp-prod50.1%
Simplified50.1%
metadata-eval50.1%
prod-exp50.1%
pow-prod-down50.9%
pow250.9%
pow-exp50.6%
*-commutative50.6%
log1p-udef50.6%
+-commutative50.6%
pow-to-exp50.5%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
unpow298.4%
+-commutative98.4%
Simplified98.4%
+-commutative98.4%
add-cube-cbrt98.0%
pow398.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 11.1%
unpow1/311.1%
Simplified11.1%
if -0.94999999999999996 < x < 2.7000000000000002Initial program 100.0%
add-cube-cbrt100.0%
pow3100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 56.1%
associate--l+56.1%
*-commutative56.1%
metadata-eval56.1%
pow-base-156.1%
unpow1/398.6%
*-lft-identity98.6%
Simplified98.6%
Final simplification54.5%
(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.1%
add-cube-cbrt52.6%
pow352.6%
Applied egg-rr52.6%
Taylor expanded in x around 0 29.0%
associate--l+29.0%
*-commutative29.0%
metadata-eval29.0%
pow-base-129.0%
unpow1/350.4%
*-lft-identity50.4%
Simplified50.4%
Final simplification50.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 53.1%
add-cube-cbrt52.6%
pow352.6%
Applied egg-rr52.6%
Taylor expanded in x around 0 28.0%
metadata-eval28.0%
pow-base-128.0%
unpow1/350.0%
*-lft-identity50.0%
Simplified50.0%
Final simplification50.0%
(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.1%
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 53.1%
Taylor expanded in x around 0 48.9%
Final simplification48.9%
herbie shell --seed 2024019
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))