
(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 14 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 (* (cbrt x) (+ (cbrt x) t_1)))
(/ 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 / (cbrt(x) * (cbrt(x) + t_1));
} 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 / Float64(cbrt(x) * Float64(cbrt(x) + t_1))); 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] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$1), $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}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_1\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.5%
associate-*r/2.5%
*-rgt-identity2.5%
+-commutative2.5%
associate--l+53.0%
+-inverses53.0%
metadata-eval53.0%
+-commutative53.0%
exp-prod52.7%
Simplified52.7%
Taylor expanded in x around inf 43.7%
unpow1/345.8%
Simplified45.8%
expm1-log1p-u45.8%
expm1-udef4.6%
+-commutative4.6%
unpow24.6%
cbrt-prod4.6%
pow24.6%
Applied egg-rr4.6%
expm1-def98.5%
expm1-log1p98.5%
fma-udef98.5%
unpow298.5%
distribute-lft-out98.5%
+-commutative98.5%
Simplified98.5%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
flip3--98.5%
div-inv98.5%
rem-cube-cbrt98.2%
rem-cube-cbrt99.8%
+-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
fma-def99.8%
add-exp-log99.8%
Applied egg-rr98.6%
associate-*r/98.6%
*-rgt-identity98.6%
+-commutative98.6%
associate--l+98.6%
+-inverses98.6%
metadata-eval98.6%
+-commutative98.6%
exp-prod98.6%
Simplified98.6%
add-sqr-sqrt98.6%
unpow-prod-down98.5%
Applied egg-rr98.5%
pow-sqr98.6%
Simplified98.6%
*-commutative98.6%
pow-unpow98.5%
pow1/298.5%
pow-exp98.5%
metadata-eval98.5%
pow-exp98.5%
log1p-udef98.5%
log-pow98.5%
pow1/398.5%
add-exp-log99.8%
pow299.8%
cbrt-unprod99.8%
pow299.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.3%
(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 (* (cbrt x) (+ (cbrt x) t_1)))
(/ (- (+ 1.0 x) x) (+ (pow t_0 2.0) (* (cbrt x) t_1))))))
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 / (cbrt(x) * (cbrt(x) + t_1));
} else {
tmp = ((1.0 + x) - x) / (pow(t_0, 2.0) + (cbrt(x) * t_1));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = Math.cbrt(x) + t_0;
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + t_1));
} else {
tmp = ((1.0 + x) - x) / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * t_1));
}
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 / Float64(cbrt(x) * Float64(cbrt(x) + t_1))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * 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[(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] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1), $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}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{{t_0}^{2} + \sqrt[3]{x} \cdot t_1}\\
\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.5%
associate-*r/2.5%
*-rgt-identity2.5%
+-commutative2.5%
associate--l+53.0%
+-inverses53.0%
metadata-eval53.0%
+-commutative53.0%
exp-prod52.7%
Simplified52.7%
Taylor expanded in x around inf 43.7%
unpow1/345.8%
Simplified45.8%
expm1-log1p-u45.8%
expm1-udef4.6%
+-commutative4.6%
unpow24.6%
cbrt-prod4.6%
pow24.6%
Applied egg-rr4.6%
expm1-def98.5%
expm1-log1p98.5%
fma-udef98.5%
unpow298.5%
distribute-lft-out98.5%
+-commutative98.5%
Simplified98.5%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
flip-+98.3%
cbrt-div98.3%
metadata-eval98.3%
fma-neg98.3%
metadata-eval98.3%
sub-neg98.3%
metadata-eval98.3%
Applied egg-rr98.3%
Applied egg-rr99.8%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 4e-6)
(/ 1.0 (* (cbrt x) (+ (cbrt x) t_1)))
(/ 1.0 (fma (cbrt x) t_1 (pow (+ 1.0 x) 0.6666666666666666))))))
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)) <= 4e-6) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + t_1));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow((1.0 + x), 0.6666666666666666));
}
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)) <= 4e-6) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + t_1))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, (Float64(1.0 + x) ^ 0.6666666666666666))); 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], 4e-6], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $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 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 5.9%
flip3--6.4%
div-inv6.4%
rem-cube-cbrt5.5%
rem-cube-cbrt7.8%
+-commutative7.8%
distribute-rgt-out7.8%
+-commutative7.8%
fma-def7.8%
add-exp-log7.8%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+52.9%
+-inverses52.9%
metadata-eval52.9%
+-commutative52.9%
exp-prod52.6%
Simplified52.6%
Taylor expanded in x around inf 44.7%
unpow1/346.7%
Simplified46.7%
expm1-log1p-u46.7%
expm1-udef6.8%
+-commutative6.8%
unpow26.8%
cbrt-prod6.8%
pow26.8%
Applied egg-rr6.8%
expm1-def97.5%
expm1-log1p97.5%
fma-udef97.4%
unpow297.4%
distribute-lft-out97.5%
+-commutative97.5%
Simplified97.5%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
flip3--99.6%
div-inv99.5%
rem-cube-cbrt99.6%
rem-cube-cbrt99.9%
+-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
fma-def99.9%
add-exp-log99.8%
Applied egg-rr99.9%
associate-*r/99.9%
*-rgt-identity99.9%
+-commutative99.9%
associate--l+99.9%
+-inverses99.9%
metadata-eval99.9%
+-commutative99.9%
exp-prod99.9%
Simplified99.9%
add-sqr-sqrt99.9%
unpow-prod-down99.9%
Applied egg-rr99.9%
pow-sqr99.9%
Simplified99.9%
*-commutative99.9%
pow-unpow99.9%
pow1/299.9%
pow-exp99.9%
metadata-eval99.9%
pow-exp99.9%
log1p-udef99.9%
log-pow99.9%
pow1/399.8%
add-exp-log99.9%
pow299.9%
+-commutative99.9%
+-commutative99.9%
Applied egg-rr99.9%
pow299.9%
pow1/399.9%
+-commutative99.9%
pow-pow99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (/ 1.0 t_0))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (/ 1.0 (* t_1 t_1))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = 1.0 / t_0;
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), (1.0 / (t_1 * t_1)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(1.0 / t_0) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), Float64(1.0 / Float64(t_1 * t_1)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / t$95$0), $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \frac{1}{t_0}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \frac{1}{t_1 \cdot t_1}\right)}
\end{array}
\end{array}
Initial program 60.5%
flip3--60.6%
div-inv60.6%
rem-cube-cbrt60.3%
rem-cube-cbrt61.4%
+-commutative61.4%
distribute-rgt-out61.4%
+-commutative61.4%
fma-def61.4%
add-exp-log61.4%
Applied egg-rr59.9%
associate-*r/59.9%
*-rgt-identity59.9%
+-commutative59.9%
associate--l+80.2%
+-inverses80.2%
metadata-eval80.2%
+-commutative80.2%
exp-prod80.1%
Simplified80.1%
add-sqr-sqrt80.1%
unpow-prod-down80.4%
Applied egg-rr80.4%
pow-sqr80.4%
Simplified80.4%
*-commutative80.4%
pow-unpow80.4%
pow1/280.4%
pow-exp80.4%
metadata-eval80.4%
pow-exp80.2%
log1p-udef80.2%
log-pow80.4%
pow1/380.5%
add-exp-log99.3%
pow299.3%
+-commutative99.3%
+-commutative99.3%
Applied egg-rr99.3%
cbrt-unprod78.1%
metadata-eval78.1%
sub-neg78.1%
flip--78.1%
metadata-eval78.1%
fma-neg78.1%
metadata-eval78.1%
metadata-eval78.1%
sub-neg78.1%
flip--78.1%
metadata-eval78.1%
fma-neg78.1%
metadata-eval78.1%
add-cube-cbrt78.1%
cbrt-undiv78.1%
cbrt-undiv78.1%
cbrt-undiv78.1%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 4e-6)
(/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) t_0))))
(- (pow (exp 0.3333333333333333) (log1p 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 / (cbrt(x) * (cbrt(x) + (cbrt(x) + t_0)));
} else {
tmp = pow(exp(0.3333333333333333), log1p(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)) <= 4e-6) {
tmp = 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + t_0)));
} else {
tmp = Math.pow(Math.exp(0.3333333333333333), Math.log1p(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)) <= 4e-6) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + t_0)))); else tmp = Float64((exp(0.3333333333333333) ^ log1p(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] + N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Exp[0.3333333333333333], $MachinePrecision], N[Log[1 + x], $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}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + t_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{0.3333333333333333}\right)}^{\left(\mathsf{log1p}\left(x\right)\right)} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 5.9%
flip3--6.4%
div-inv6.4%
rem-cube-cbrt5.5%
rem-cube-cbrt7.8%
+-commutative7.8%
distribute-rgt-out7.8%
+-commutative7.8%
fma-def7.8%
add-exp-log7.8%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+52.9%
+-inverses52.9%
metadata-eval52.9%
+-commutative52.9%
exp-prod52.6%
Simplified52.6%
Taylor expanded in x around inf 44.7%
unpow1/346.7%
Simplified46.7%
expm1-log1p-u46.7%
expm1-udef6.8%
+-commutative6.8%
unpow26.8%
cbrt-prod6.8%
pow26.8%
Applied egg-rr6.8%
expm1-def97.5%
expm1-log1p97.5%
fma-udef97.4%
unpow297.4%
distribute-lft-out97.5%
+-commutative97.5%
Simplified97.5%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
add-exp-log99.6%
pow1/399.6%
log-pow99.6%
+-commutative99.6%
log1p-udef99.6%
Applied egg-rr99.6%
exp-prod99.7%
Simplified99.7%
Final simplification98.8%
(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))
(exp (* 0.3333333333333333 (* 3.0 (log 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 = exp((0.3333333333333333 * (3.0 * log(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 = exp(Float64(0.3333333333333333 * Float64(3.0 * log(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], N[Exp[N[(0.3333333333333333 * N[(3.0 * N[Log[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\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}:\\
\;\;\;\;e^{0.3333333333333333 \cdot \left(3 \cdot \log t_1\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.5%
associate-*r/2.5%
*-rgt-identity2.5%
+-commutative2.5%
associate--l+53.0%
+-inverses53.0%
metadata-eval53.0%
+-commutative53.0%
exp-prod52.7%
Simplified52.7%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.3%
add-cbrt-cube98.2%
pow1/398.3%
pow-to-exp98.3%
pow398.3%
log-pow98.3%
Applied egg-rr98.3%
Final simplification66.8%
(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 60.5%
flip3--60.6%
div-inv60.6%
rem-cube-cbrt60.3%
rem-cube-cbrt61.4%
+-commutative61.4%
distribute-rgt-out61.4%
+-commutative61.4%
fma-def61.4%
add-exp-log61.4%
Applied egg-rr59.9%
associate-*r/59.9%
*-rgt-identity59.9%
+-commutative59.9%
associate--l+80.2%
+-inverses80.2%
metadata-eval80.2%
+-commutative80.2%
exp-prod80.1%
Simplified80.1%
add-sqr-sqrt80.1%
unpow-prod-down80.4%
Applied egg-rr80.4%
pow-sqr80.4%
Simplified80.4%
*-commutative80.4%
pow-unpow80.4%
pow1/280.4%
pow-exp80.4%
metadata-eval80.4%
pow-exp80.2%
log1p-udef80.2%
log-pow80.4%
pow1/380.5%
add-exp-log99.3%
pow299.3%
+-commutative99.3%
+-commutative99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (exp (* 0.3333333333333333 (* 3.0 (log (- (cbrt (+ 1.0 x)) (cbrt x)))))))
double code(double x) {
return exp((0.3333333333333333 * (3.0 * log((cbrt((1.0 + x)) - cbrt(x))))));
}
public static double code(double x) {
return Math.exp((0.3333333333333333 * (3.0 * Math.log((Math.cbrt((1.0 + x)) - Math.cbrt(x))))));
}
function code(x) return exp(Float64(0.3333333333333333 * Float64(3.0 * log(Float64(cbrt(Float64(1.0 + x)) - cbrt(x)))))) end
code[x_] := N[Exp[N[(0.3333333333333333 * N[(3.0 * N[Log[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{0.3333333333333333 \cdot \left(3 \cdot \log \left(\sqrt[3]{1 + x} - \sqrt[3]{x}\right)\right)}
\end{array}
Initial program 60.5%
add-cbrt-cube60.4%
pow1/360.5%
pow-to-exp60.5%
pow360.5%
log-pow60.5%
Applied egg-rr60.5%
Final simplification60.5%
(FPCore (x) :precision binary64 (pow (pow (- (cbrt (+ 1.0 x)) (cbrt x)) 3.0) 0.3333333333333333))
double code(double x) {
return pow(pow((cbrt((1.0 + x)) - cbrt(x)), 3.0), 0.3333333333333333);
}
public static double code(double x) {
return Math.pow(Math.pow((Math.cbrt((1.0 + x)) - Math.cbrt(x)), 3.0), 0.3333333333333333);
}
function code(x) return (Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) ^ 3.0) ^ 0.3333333333333333 end
code[x_] := N[Power[N[Power[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]
\begin{array}{l}
\\
{\left({\left(\sqrt[3]{1 + x} - \sqrt[3]{x}\right)}^{3}\right)}^{0.3333333333333333}
\end{array}
Initial program 60.5%
add-cbrt-cube60.4%
pow1/360.5%
pow360.5%
Applied egg-rr60.5%
Final simplification60.5%
(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 60.5%
Final simplification60.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 60.5%
add-cube-cbrt60.1%
pow360.0%
Applied egg-rr60.0%
Taylor expanded in x around 0 31.1%
associate--l+31.1%
*-commutative31.1%
metadata-eval31.1%
pow-base-131.1%
unpow1/358.2%
*-lft-identity58.2%
Simplified58.2%
Final simplification58.2%
(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 60.5%
add-cube-cbrt60.1%
pow360.0%
Applied egg-rr60.0%
Taylor expanded in x around 0 30.5%
metadata-eval30.5%
pow-base-130.5%
unpow1/357.9%
*-lft-identity57.9%
Simplified57.9%
Final simplification57.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 60.5%
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 60.5%
Taylor expanded in x around 0 56.6%
Final simplification56.6%
herbie shell --seed 2023315
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))