
(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.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.7%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+50.0%
+-inverses50.0%
metadata-eval50.0%
+-commutative50.0%
exp-prod49.8%
Simplified49.8%
Taylor expanded in x around inf 49.7%
unpow1/352.2%
Simplified52.2%
unpow252.2%
cbrt-prod98.6%
pow298.6%
Applied egg-rr98.6%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 96.7%
flip3--97.8%
div-inv97.8%
rem-cube-cbrt97.2%
rem-cube-cbrt99.8%
+-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
fma-def99.8%
add-exp-log99.8%
Applied egg-rr95.6%
associate-*r/95.6%
*-rgt-identity95.6%
+-commutative95.6%
associate--l+95.6%
+-inverses95.6%
metadata-eval95.6%
+-commutative95.6%
exp-prod95.6%
Simplified95.6%
add-sqr-sqrt95.6%
unpow-prod-down95.5%
Applied egg-rr95.5%
pow-sqr95.6%
Simplified95.6%
add-sqr-sqrt95.5%
pow295.5%
pow-sqr95.5%
pow-prod-down95.5%
add-sqr-sqrt95.5%
sqrt-pow195.5%
add-sqr-sqrt95.5%
pow-prod-down95.5%
sqr-pow95.5%
pow1/295.5%
pow-exp95.5%
metadata-eval95.5%
pow295.5%
add-exp-log95.5%
pow-to-exp95.5%
prod-exp95.5%
Applied egg-rr99.8%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-7)
(/ 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)) <= 5e-7) {
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)) <= 5e-7) 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], 5e-7], 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 5 \cdot 10^{-7}:\\
\;\;\;\;\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)) < 4.99999999999999977e-7Initial program 5.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt5.8%
rem-cube-cbrt8.8%
+-commutative8.8%
distribute-rgt-out8.8%
+-commutative8.8%
fma-def8.8%
add-exp-log8.7%
Applied egg-rr3.7%
associate-*r/3.7%
*-rgt-identity3.7%
+-commutative3.7%
associate--l+49.1%
+-inverses49.1%
metadata-eval49.1%
+-commutative49.1%
exp-prod48.9%
Simplified48.9%
Taylor expanded in x around inf 51.2%
unpow1/353.6%
Simplified53.6%
unpow253.6%
cbrt-prod97.7%
pow297.7%
Applied egg-rr97.7%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.2%
pow1/398.2%
flip3-+98.2%
div-inv98.2%
unpow-prod-down98.2%
pow398.2%
metadata-eval98.2%
+-commutative98.2%
pow398.2%
metadata-eval98.2%
*-rgt-identity98.2%
associate-+r-98.2%
fma-def98.2%
Applied egg-rr98.2%
unpow1/399.2%
unpow1/399.3%
Simplified99.3%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-7)
(/ 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)) <= 5e-7) {
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)) <= 5e-7) 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], 5e-7], 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 5 \cdot 10^{-7}:\\
\;\;\;\;\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)) < 4.99999999999999977e-7Initial program 5.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt5.8%
rem-cube-cbrt8.8%
+-commutative8.8%
distribute-rgt-out8.8%
+-commutative8.8%
fma-def8.8%
add-exp-log8.7%
Applied egg-rr3.7%
associate-*r/3.7%
*-rgt-identity3.7%
+-commutative3.7%
associate--l+49.1%
+-inverses49.1%
metadata-eval49.1%
+-commutative49.1%
exp-prod48.9%
Simplified48.9%
Taylor expanded in x around inf 51.2%
unpow1/353.6%
Simplified53.6%
fma-udef53.6%
+-commutative53.6%
unpow253.6%
cbrt-prod97.7%
pow297.7%
+-commutative97.7%
+-commutative97.7%
Applied egg-rr97.7%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.2%
pow1/398.2%
flip3-+98.2%
div-inv98.2%
unpow-prod-down98.2%
pow398.2%
metadata-eval98.2%
+-commutative98.2%
pow398.2%
metadata-eval98.2%
*-rgt-identity98.2%
associate-+r-98.2%
fma-def98.2%
Applied egg-rr98.2%
unpow1/399.2%
unpow1/399.3%
Simplified99.3%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-7)
(/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) t_0))))
(- (/ (cbrt (+ 1.0 (pow x 3.0))) (cbrt (- (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)) <= 5e-7) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + t_0)));
} else {
tmp = (cbrt((1.0 + pow(x, 3.0))) / cbrt((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)) <= 5e-7) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + t_0)))); else tmp = Float64(Float64(cbrt(Float64(1.0 + (x ^ 3.0))) / cbrt(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], 5e-7], 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], N[(N[(N[Power[N[(1.0 + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(N[(x * x + 1.0), $MachinePrecision] - x), $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^{-7}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + t_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 + {x}^{3}}}{\sqrt[3]{\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)) < 4.99999999999999977e-7Initial program 5.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt5.8%
rem-cube-cbrt8.8%
+-commutative8.8%
distribute-rgt-out8.8%
+-commutative8.8%
fma-def8.8%
add-exp-log8.7%
Applied egg-rr3.7%
associate-*r/3.7%
*-rgt-identity3.7%
+-commutative3.7%
associate--l+49.1%
+-inverses49.1%
metadata-eval49.1%
+-commutative49.1%
exp-prod48.9%
Simplified48.9%
Taylor expanded in x around inf 51.2%
unpow1/353.6%
Simplified53.6%
expm1-log1p-u53.6%
expm1-udef7.4%
+-commutative7.4%
+-commutative7.4%
unpow27.4%
cbrt-prod7.4%
pow27.4%
Applied egg-rr7.4%
expm1-def97.7%
expm1-log1p97.7%
fma-def97.7%
+-commutative97.7%
unpow297.7%
distribute-lft-out97.7%
+-commutative97.7%
+-commutative97.7%
Simplified97.7%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.2%
flip3-+99.3%
cbrt-div99.3%
pow399.2%
metadata-eval99.2%
+-commutative99.2%
pow399.3%
metadata-eval99.3%
*-rgt-identity99.3%
associate-+r-99.3%
fma-def99.3%
Applied egg-rr99.3%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-7)
(/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) (+ (cbrt x) t_0))))
(- (/ (cbrt (+ 1.0 (pow x 3.0))) (cbrt (- (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)) <= 5e-7) {
tmp = 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = (cbrt((1.0 + pow(x, 3.0))) / cbrt((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)) <= 5e-7) 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(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], 5e-7], 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[(N[(x * x + 1.0), $MachinePrecision] - x), $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^{-7}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 + {x}^{3}}}{\sqrt[3]{\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)) < 4.99999999999999977e-7Initial program 5.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt5.8%
rem-cube-cbrt8.8%
+-commutative8.8%
distribute-rgt-out8.8%
+-commutative8.8%
fma-def8.8%
add-exp-log8.7%
Applied egg-rr3.7%
associate-*r/3.7%
*-rgt-identity3.7%
+-commutative3.7%
associate--l+49.1%
+-inverses49.1%
metadata-eval49.1%
+-commutative49.1%
exp-prod48.9%
Simplified48.9%
Taylor expanded in x around inf 51.2%
unpow1/353.6%
Simplified53.6%
fma-udef53.6%
+-commutative53.6%
unpow253.6%
cbrt-prod97.7%
pow297.7%
+-commutative97.7%
+-commutative97.7%
Applied egg-rr97.7%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.2%
flip3-+99.3%
cbrt-div99.3%
pow399.2%
metadata-eval99.2%
+-commutative99.2%
pow399.3%
metadata-eval99.3%
*-rgt-identity99.3%
associate-+r-99.3%
fma-def99.3%
Applied egg-rr99.3%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-7)
(/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) t_0))))
(- (/ (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-7) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + t_0)));
} 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-7) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + t_0)))); 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-7], 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], 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^{-7}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + t_0\right)\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)) < 4.99999999999999977e-7Initial program 5.9%
flip3--6.9%
div-inv6.9%
rem-cube-cbrt5.8%
rem-cube-cbrt8.8%
+-commutative8.8%
distribute-rgt-out8.8%
+-commutative8.8%
fma-def8.8%
add-exp-log8.7%
Applied egg-rr3.7%
associate-*r/3.7%
*-rgt-identity3.7%
+-commutative3.7%
associate--l+49.1%
+-inverses49.1%
metadata-eval49.1%
+-commutative49.1%
exp-prod48.9%
Simplified48.9%
Taylor expanded in x around inf 51.2%
unpow1/353.6%
Simplified53.6%
expm1-log1p-u53.6%
expm1-udef7.4%
+-commutative7.4%
+-commutative7.4%
unpow27.4%
cbrt-prod7.4%
pow27.4%
Applied egg-rr7.4%
expm1-def97.7%
expm1-log1p97.7%
fma-def97.7%
+-commutative97.7%
unpow297.7%
distribute-lft-out97.7%
+-commutative97.7%
+-commutative97.7%
Simplified97.7%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.2%
flip-+99.2%
cbrt-div99.3%
metadata-eval99.3%
fma-neg99.3%
metadata-eval99.3%
sub-neg99.3%
metadata-eval99.3%
Applied egg-rr99.3%
Final simplification98.5%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x)))) (if (<= t_1 0.0) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.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 <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.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 <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.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, 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + 1.0), $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 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.7%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+50.0%
+-inverses50.0%
metadata-eval50.0%
+-commutative50.0%
exp-prod49.8%
Simplified49.8%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 96.7%
Final simplification61.6%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (* t_0 t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), (t_0 * t_0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), Float64(t_0 * t_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[(t$95$0 * t$95$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 \cdot t_0\right)}
\end{array}
\end{array}
Initial program 54.4%
flip3--55.0%
div-inv55.0%
rem-cube-cbrt54.4%
rem-cube-cbrt56.1%
+-commutative56.1%
distribute-rgt-out56.1%
+-commutative56.1%
fma-def56.1%
add-exp-log56.1%
Applied egg-rr52.9%
associate-*r/52.9%
*-rgt-identity52.9%
+-commutative52.9%
associate--l+74.7%
+-inverses74.7%
metadata-eval74.7%
+-commutative74.7%
exp-prod74.6%
Simplified74.6%
add-sqr-sqrt74.6%
unpow-prod-down75.0%
Applied egg-rr75.0%
pow-sqr75.1%
Simplified75.1%
add-sqr-sqrt75.0%
pow275.0%
pow-sqr75.0%
pow-prod-down74.6%
add-sqr-sqrt74.6%
sqrt-pow174.6%
add-sqr-sqrt74.6%
pow-prod-down75.0%
sqr-pow75.0%
pow1/275.0%
pow-exp75.0%
metadata-eval75.0%
pow275.0%
add-exp-log75.0%
pow-to-exp74.8%
prod-exp74.7%
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 54.4%
Final simplification54.4%
(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 54.4%
add-cube-cbrt54.2%
pow354.2%
Applied egg-rr54.2%
Taylor expanded in x around 0 26.7%
associate--l+26.7%
*-commutative26.7%
metadata-eval26.7%
pow-base-126.7%
unpow1/351.4%
*-lft-identity51.4%
Simplified51.4%
Final simplification51.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 54.4%
add-cube-cbrt54.2%
pow354.2%
Applied egg-rr54.2%
Taylor expanded in x around 0 25.6%
metadata-eval25.6%
pow-base-125.6%
unpow1/351.3%
*-lft-identity51.3%
Simplified51.3%
Final simplification51.3%
(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 54.4%
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 54.4%
Taylor expanded in x around 0 51.2%
Final simplification51.2%
herbie shell --seed 2024024
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))