
(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 11 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))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow t_0 2.0)))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (cbrt (pow (+ 1.0 x) 2.0)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(t_0, 2.0));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), cbrt(pow((1.0 + x), 2.0)));
}
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 / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (t_0 ^ 2.0))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 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]}, 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] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[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}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {t_0}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \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%
cbrt-unprod4.3%
pow24.3%
distribute-rgt-out4.3%
+-commutative4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+46.9%
+-inverses46.9%
metadata-eval46.9%
+-commutative46.9%
fma-def46.9%
+-commutative46.9%
+-commutative46.9%
Simplified46.9%
pow1/344.7%
pow-pow43.9%
pow-sqr43.9%
+-commutative43.9%
pow1/344.7%
+-commutative44.7%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
+-commutative98.4%
add-cube-cbrt98.3%
pow398.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 44.7%
unpow1/398.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 96.7%
flip3--96.6%
div-inv96.6%
rem-cube-cbrt96.6%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
+-commutative99.8%
associate--l+99.8%
+-inverses99.8%
metadata-eval99.8%
+-commutative99.8%
fma-def99.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow t_0 2.0)))
(/
(- (+ 1.0 x) x)
(+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) (+ (cbrt x) t_0)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(t_0, 2.0));
} else {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * (cbrt(x) + t_0)));
}
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 / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (t_0 ^ 2.0))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); 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[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {t_0}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\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%
cbrt-unprod4.3%
pow24.3%
distribute-rgt-out4.3%
+-commutative4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+46.9%
+-inverses46.9%
metadata-eval46.9%
+-commutative46.9%
fma-def46.9%
+-commutative46.9%
+-commutative46.9%
Simplified46.9%
pow1/344.7%
pow-pow43.9%
pow-sqr43.9%
+-commutative43.9%
pow1/344.7%
+-commutative44.7%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
+-commutative98.4%
add-cube-cbrt98.3%
pow398.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 44.7%
unpow1/398.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 96.7%
flip3--96.6%
rem-cube-cbrt96.6%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 1e-9)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (cbrt (* x x))))
(- (+ 1.0 (+ t_0 -1.0)) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 1e-9) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), cbrt((x * x)));
} else {
tmp = (1.0 + (t_0 + -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)) <= 1e-9) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), cbrt(Float64(x * x)))); else tmp = Float64(Float64(1.0 + Float64(t_0 + -1.0)) - cbrt(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 1e-9], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 10^{-9}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \sqrt[3]{x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(t_0 + -1\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000006e-9Initial program 5.1%
flip3--5.1%
div-inv5.1%
rem-cube-cbrt4.8%
rem-cube-cbrt8.1%
cbrt-unprod8.1%
pow28.1%
distribute-rgt-out8.1%
+-commutative8.1%
Applied egg-rr8.1%
associate-*r/8.1%
*-rgt-identity8.1%
+-commutative8.1%
associate--l+49.0%
+-inverses49.0%
metadata-eval49.0%
+-commutative49.0%
fma-def49.0%
+-commutative49.0%
+-commutative49.0%
Simplified49.0%
pow1/346.9%
pow-pow43.7%
pow-sqr43.7%
+-commutative43.7%
pow1/344.5%
+-commutative44.5%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
add-exp-log93.9%
log-pow44.3%
pow1/344.0%
log-pow43.9%
log1p-udef43.9%
Applied egg-rr43.9%
associate-*r*43.9%
metadata-eval43.9%
Simplified43.9%
Taylor expanded in x around inf 46.7%
unpow1/348.8%
unpow248.8%
Simplified48.8%
if 1.00000000000000006e-9 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.3%
expm1-log1p-u98.0%
expm1-udef98.0%
log1p-udef98.0%
add-exp-log99.3%
Applied egg-rr99.3%
associate--l+99.3%
+-commutative99.3%
Simplified99.3%
Final simplification75.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) (+ 1.0 (cbrt x)) (pow t_0 2.0)))
(- (+ 1.0 (+ t_0 -1.0)) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (1.0 + cbrt(x)), pow(t_0, 2.0));
} else {
tmp = (1.0 + (t_0 + -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 / fma(cbrt(x), Float64(1.0 + cbrt(x)), (t_0 ^ 2.0))); else tmp = Float64(Float64(1.0 + Float64(t_0 + -1.0)) - cbrt(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, 1 + \sqrt[3]{x}, {t_0}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(t_0 + -1\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt4.3%
cbrt-unprod4.3%
pow24.3%
distribute-rgt-out4.3%
+-commutative4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+46.9%
+-inverses46.9%
metadata-eval46.9%
+-commutative46.9%
fma-def46.9%
+-commutative46.9%
+-commutative46.9%
Simplified46.9%
pow1/344.7%
pow-pow43.9%
pow-sqr43.9%
+-commutative43.9%
pow1/344.7%
+-commutative44.7%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
+-commutative98.4%
add-cube-cbrt98.3%
pow398.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 96.7%
expm1-log1p-u94.8%
expm1-udef94.8%
log1p-udef94.9%
add-exp-log96.6%
Applied egg-rr96.6%
associate--l+96.7%
+-commutative96.7%
Simplified96.7%
Final simplification61.3%
(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 54.1%
flip3--54.0%
div-inv54.0%
rem-cube-cbrt53.9%
rem-cube-cbrt55.7%
cbrt-unprod55.8%
pow255.8%
distribute-rgt-out55.8%
+-commutative55.8%
Applied egg-rr55.8%
associate-*r/55.8%
*-rgt-identity55.8%
+-commutative55.8%
associate--l+75.4%
+-inverses75.4%
metadata-eval75.4%
+-commutative75.4%
fma-def75.4%
+-commutative75.4%
+-commutative75.4%
Simplified75.4%
pow1/374.4%
pow-pow72.1%
pow-sqr72.1%
+-commutative72.1%
pow1/372.5%
+-commutative72.5%
pow1/399.1%
pow299.1%
+-commutative99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (+ 1.0 (* (cbrt x) (+ (cbrt x) t_0))))
(- (+ 1.0 (+ t_0 -1.0)) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / (1.0 + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = (1.0 + (t_0 + -1.0)) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
} else {
tmp = (1.0 + (t_0 + -1.0)) - Math.cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); else tmp = Float64(Float64(1.0 + Float64(t_0 + -1.0)) - cbrt(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(t_0 + -1\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt4.3%
cbrt-unprod4.3%
pow24.3%
distribute-rgt-out4.3%
+-commutative4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+46.9%
+-inverses46.9%
metadata-eval46.9%
+-commutative46.9%
fma-def46.9%
+-commutative46.9%
+-commutative46.9%
Simplified46.9%
Taylor expanded in x around 0 20.0%
fma-udef20.0%
Applied egg-rr20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 96.7%
expm1-log1p-u94.8%
expm1-udef94.8%
log1p-udef94.9%
add-exp-log96.6%
Applied egg-rr96.6%
associate--l+96.7%
+-commutative96.7%
Simplified96.7%
Final simplification61.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.32e+154)
(/ 1.0 (+ 1.0 (* (cbrt x) t_0)))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (* x x))))
(/ 1.0 (fma (cbrt x) t_0 (pow (+ 1.0 x) 0.6666666666666666)))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= -1.32e+154) {
tmp = 1.0 / (1.0 + (cbrt(x) * t_0));
} else if (x <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt((x * x)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= -1.32e+154) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * t_0))); elseif (x <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt(Float64(x * x)))); 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[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.32e+154], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(x * x), $MachinePrecision], 1/3], $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]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot t_0}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{x \cdot x}\right)}\\
\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 < -1.31999999999999998e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.7%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
Taylor expanded in x around 0 19.9%
fma-udef19.9%
Applied egg-rr19.9%
if -1.31999999999999998e154 < x < -1Initial program 10.6%
flip3--10.6%
div-inv10.6%
rem-cube-cbrt11.8%
rem-cube-cbrt18.6%
cbrt-unprod18.5%
pow218.5%
distribute-rgt-out18.5%
+-commutative18.5%
Applied egg-rr18.5%
associate-*r/18.5%
*-rgt-identity18.5%
+-commutative18.5%
associate--l+98.7%
+-inverses98.7%
metadata-eval98.7%
+-commutative98.7%
fma-def98.7%
+-commutative98.7%
+-commutative98.7%
Simplified98.7%
pow1/394.5%
pow-pow0.0%
pow-sqr0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/398.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
add-exp-log95.4%
log-pow0.0%
pow1/30.0%
log-pow0.0%
log1p-udef0.0%
Applied egg-rr0.0%
associate-*r*0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in x around inf 90.3%
unpow1/394.3%
unpow294.3%
Simplified94.3%
if -1 < x Initial program 70.6%
flip3--70.5%
div-inv70.5%
rem-cube-cbrt70.3%
rem-cube-cbrt71.5%
cbrt-unprod71.5%
pow271.5%
distribute-rgt-out71.5%
+-commutative71.5%
Applied egg-rr71.5%
associate-*r/71.5%
*-rgt-identity71.5%
+-commutative71.5%
associate--l+84.6%
+-inverses84.6%
metadata-eval84.6%
+-commutative84.6%
fma-def84.6%
+-commutative84.6%
+-commutative84.6%
Simplified84.6%
pow1/383.9%
pow-pow97.7%
metadata-eval97.7%
Applied egg-rr97.7%
Final simplification86.6%
(FPCore (x) :precision binary64 (- (+ 1.0 (+ (cbrt (+ 1.0 x)) -1.0)) (cbrt x)))
double code(double x) {
return (1.0 + (cbrt((1.0 + x)) + -1.0)) - cbrt(x);
}
public static double code(double x) {
return (1.0 + (Math.cbrt((1.0 + x)) + -1.0)) - Math.cbrt(x);
}
function code(x) return Float64(Float64(1.0 + Float64(cbrt(Float64(1.0 + x)) + -1.0)) - cbrt(x)) end
code[x_] := N[(N[(1.0 + N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + \left(\sqrt[3]{1 + x} + -1\right)\right) - \sqrt[3]{x}
\end{array}
Initial program 54.1%
expm1-log1p-u51.9%
expm1-udef51.9%
log1p-udef51.9%
add-exp-log54.1%
Applied egg-rr54.1%
associate--l+54.1%
+-commutative54.1%
Simplified54.1%
Final simplification54.1%
(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.1%
Final simplification54.1%
(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.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 54.1%
Taylor expanded in x around 0 49.7%
Final simplification49.7%
herbie shell --seed 2023230
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))