
(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 (* (cbrt x) (+ t_0 (* (cbrt x) 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 / (cbrt(x) * (t_0 + (cbrt(x) * 2.0)));
} else {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * (cbrt(x) + t_0)));
}
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 / (Math.cbrt(x) * (t_0 + (Math.cbrt(x) * 2.0)));
} else {
tmp = ((1.0 + x) - x) / (Math.cbrt(Math.pow((1.0 + x), 2.0)) + (Math.cbrt(x) * (Math.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 / Float64(cbrt(x) * Float64(t_0 + Float64(cbrt(x) * 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[(t$95$0 + N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision]), $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}{\sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x} \cdot 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.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+48.6%
+-inverses48.6%
metadata-eval48.6%
+-commutative48.6%
fma-def48.6%
+-commutative48.6%
+-commutative48.6%
Simplified48.6%
pow1/346.4%
pow-pow44.7%
metadata-eval44.7%
Applied egg-rr44.7%
Taylor expanded in x around inf 46.4%
unpow1/348.6%
unpow248.6%
Simplified48.6%
expm1-log1p-u48.6%
expm1-udef4.8%
fma-udef4.8%
cbrt-prod4.8%
distribute-lft-out4.8%
Applied egg-rr4.8%
expm1-def98.7%
expm1-log1p98.7%
associate-+l+98.7%
count-298.7%
Simplified98.7%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.8%
flip3--98.7%
rem-cube-cbrt99.2%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 1e-9)
(/ 1.0 (* (cbrt x) (+ t_0 (* (cbrt x) 2.0))))
(/
1.0
(fma (cbrt x) (+ (cbrt x) t_0) (pow (+ 1.0 x) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 1e-9) {
tmp = 1.0 / (cbrt(x) * (t_0 + (cbrt(x) * 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow((1.0 + x), 0.6666666666666666));
}
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 / Float64(cbrt(x) * Float64(t_0 + Float64(cbrt(x) * 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (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]}, 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[(t$95$0 + N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision]), $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[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $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}{\sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x} \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000006e-9Initial program 4.4%
flip3--4.4%
div-inv4.4%
rem-cube-cbrt4.6%
rem-cube-cbrt4.9%
cbrt-unprod4.9%
pow24.9%
distribute-rgt-out4.9%
+-commutative4.9%
Applied egg-rr4.9%
associate-*r/4.9%
*-rgt-identity4.9%
+-commutative4.9%
associate--l+49.0%
+-inverses49.0%
metadata-eval49.0%
+-commutative49.0%
fma-def49.0%
+-commutative49.0%
+-commutative49.0%
Simplified49.0%
pow1/346.8%
pow-pow44.4%
metadata-eval44.4%
Applied egg-rr44.4%
Taylor expanded in x around inf 46.7%
unpow1/348.9%
unpow248.9%
Simplified48.9%
expm1-log1p-u48.9%
expm1-udef5.2%
fma-udef5.2%
cbrt-prod5.2%
distribute-lft-out5.2%
Applied egg-rr5.2%
expm1-def98.6%
expm1-log1p98.6%
associate-+l+98.6%
count-298.6%
Simplified98.6%
if 1.00000000000000006e-9 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.4%
flip3--99.2%
div-inv99.2%
rem-cube-cbrt99.2%
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%
pow1/399.8%
pow-pow99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.2%
(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(Float64(1.0 / 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[(N[(1.0 / t$95$1), $MachinePrecision] / t$95$1), $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{\frac{1}{t_1}}{t_1}\right)}
\end{array}
\end{array}
Initial program 51.1%
flip3--51.1%
div-inv51.1%
rem-cube-cbrt51.1%
rem-cube-cbrt51.6%
cbrt-unprod51.6%
pow251.6%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+74.0%
+-inverses74.0%
metadata-eval74.0%
+-commutative74.0%
fma-def74.0%
+-commutative74.0%
+-commutative74.0%
Simplified74.0%
unpow274.0%
+-commutative74.0%
add-cube-cbrt73.9%
+-commutative73.9%
add-cube-cbrt73.9%
swap-sqr73.9%
add-cbrt-cube99.2%
pow299.2%
metadata-eval99.2%
sub-neg99.2%
flip--73.9%
metadata-eval73.9%
fma-neg73.9%
metadata-eval73.9%
cbrt-undiv74.1%
pow274.1%
clear-num74.1%
Applied egg-rr99.2%
+-commutative99.2%
metadata-eval99.2%
sub-neg99.2%
flip--73.9%
metadata-eval73.9%
fma-neg73.9%
metadata-eval73.9%
cbrt-undiv74.0%
clear-num74.0%
clear-num74.0%
cbrt-undiv73.9%
metadata-eval73.9%
fma-neg73.9%
metadata-eval73.9%
flip--99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (/ t_0 (/ 1.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 / (1.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 / Float64(1.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 / N[(1.0 / t$95$0), $MachinePrecision]), $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, \frac{t_0}{\frac{1}{t_0}}\right)}
\end{array}
\end{array}
Initial program 51.1%
flip3--51.1%
div-inv51.1%
rem-cube-cbrt51.1%
rem-cube-cbrt51.6%
cbrt-unprod51.6%
pow251.6%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+74.0%
+-inverses74.0%
metadata-eval74.0%
+-commutative74.0%
fma-def74.0%
+-commutative74.0%
+-commutative74.0%
Simplified74.0%
unpow274.0%
+-commutative74.0%
add-cube-cbrt73.9%
+-commutative73.9%
add-cube-cbrt73.9%
swap-sqr73.9%
add-cbrt-cube99.2%
pow299.2%
metadata-eval99.2%
sub-neg99.2%
flip--73.9%
metadata-eval73.9%
fma-neg73.9%
metadata-eval73.9%
cbrt-undiv74.1%
pow274.1%
clear-num74.1%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (/ 1.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), (1.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), Float64(1.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[(1.0 / N[Power[t$95$0, -2.0], $MachinePrecision]), $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, \frac{1}{{t_0}^{-2}}\right)}
\end{array}
\end{array}
Initial program 51.1%
flip3--51.1%
div-inv51.1%
rem-cube-cbrt51.1%
rem-cube-cbrt51.6%
cbrt-unprod51.6%
pow251.6%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+74.0%
+-inverses74.0%
metadata-eval74.0%
+-commutative74.0%
fma-def74.0%
+-commutative74.0%
+-commutative74.0%
Simplified74.0%
pow1/372.9%
pow-pow71.7%
metadata-eval71.7%
Applied egg-rr71.7%
metadata-eval71.7%
pow-pow71.7%
pow1/399.2%
metadata-eval99.2%
pow-div99.2%
pow199.2%
inv-pow99.2%
clear-num99.2%
inv-pow99.2%
pow199.2%
pow-div99.2%
metadata-eval99.2%
Applied egg-rr99.2%
Final simplification99.2%
(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 51.1%
flip3--51.1%
div-inv51.1%
rem-cube-cbrt51.1%
rem-cube-cbrt51.6%
cbrt-unprod51.6%
pow251.6%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+74.0%
+-inverses74.0%
metadata-eval74.0%
+-commutative74.0%
fma-def74.0%
+-commutative74.0%
+-commutative74.0%
Simplified74.0%
expm1-log1p-u73.1%
expm1-udef73.1%
unpow273.1%
+-commutative73.1%
add-cube-cbrt73.1%
+-commutative73.1%
add-cube-cbrt73.1%
swap-sqr73.1%
add-cbrt-cube96.9%
pow296.9%
+-commutative96.9%
Applied egg-rr96.9%
expm1-def96.9%
expm1-log1p99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 1e-7)
(/ 1.0 (* (cbrt x) (+ t_0 (* (cbrt x) 2.0))))
(- (exp (* (log1p x) 0.3333333333333333)) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 1e-7) {
tmp = 1.0 / (cbrt(x) * (t_0 + (cbrt(x) * 2.0)));
} else {
tmp = exp((log1p(x) * 0.3333333333333333)) - 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)) <= 1e-7) {
tmp = 1.0 / (Math.cbrt(x) * (t_0 + (Math.cbrt(x) * 2.0)));
} else {
tmp = Math.exp((Math.log1p(x) * 0.3333333333333333)) - Math.cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 1e-7) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(t_0 + Float64(cbrt(x) * 2.0)))); else tmp = Float64(exp(Float64(log1p(x) * 0.3333333333333333)) - 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-7], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] * 0.3333333333333333), $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^{-7}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x} \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{log1p}\left(x\right) \cdot 0.3333333333333333} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 9.9999999999999995e-8Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt4.9%
rem-cube-cbrt5.6%
cbrt-unprod5.6%
pow25.6%
distribute-rgt-out5.6%
+-commutative5.6%
Applied egg-rr5.6%
associate-*r/5.6%
*-rgt-identity5.6%
+-commutative5.6%
associate--l+49.4%
+-inverses49.4%
metadata-eval49.4%
+-commutative49.4%
fma-def49.4%
+-commutative49.4%
+-commutative49.4%
Simplified49.4%
pow1/347.2%
pow-pow44.8%
metadata-eval44.8%
Applied egg-rr44.8%
Taylor expanded in x around inf 46.9%
unpow1/349.1%
unpow249.1%
Simplified49.1%
expm1-log1p-u49.1%
expm1-udef5.6%
fma-udef5.6%
cbrt-prod5.6%
distribute-lft-out5.6%
Applied egg-rr5.6%
expm1-def98.4%
expm1-log1p98.4%
associate-+l+98.4%
count-298.4%
Simplified98.4%
if 9.9999999999999995e-8 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.8%
pow1/399.8%
pow-to-exp99.8%
+-commutative99.8%
log1p-udef99.8%
Applied egg-rr99.8%
Final simplification99.1%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (/ 1.0 (pow (cbrt x) 2.0)) t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = 1.0 / pow(cbrt(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 <= 0.0) {
tmp = 1.0 / Math.pow(Math.cbrt(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 <= 0.0) tmp = Float64(1.0 / (cbrt(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, 0.0], N[(1.0 / N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\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.8%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+48.6%
+-inverses48.6%
metadata-eval48.6%
+-commutative48.6%
fma-def48.6%
+-commutative48.6%
+-commutative48.6%
Simplified48.6%
pow1/346.4%
pow-pow44.7%
metadata-eval44.7%
Applied egg-rr44.7%
Taylor expanded in x around inf 10.8%
unpow1/310.8%
unpow210.8%
Simplified10.8%
cbrt-div10.8%
metadata-eval10.8%
cbrt-prod17.7%
pow217.7%
Applied egg-rr17.7%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.8%
Final simplification58.0%
(FPCore (x) :precision binary64 (if (or (<= x -0.38) (not (<= x 1.4))) (/ 1.0 (pow (cbrt x) 2.0)) (+ 1.0 (* x -0.6666666666666666))))
double code(double x) {
double tmp;
if ((x <= -0.38) || !(x <= 1.4)) {
tmp = 1.0 / pow(cbrt(x), 2.0);
} else {
tmp = 1.0 + (x * -0.6666666666666666);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.38) || !(x <= 1.4)) {
tmp = 1.0 / Math.pow(Math.cbrt(x), 2.0);
} else {
tmp = 1.0 + (x * -0.6666666666666666);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.38) || !(x <= 1.4)) tmp = Float64(1.0 / (cbrt(x) ^ 2.0)); else tmp = Float64(1.0 + Float64(x * -0.6666666666666666)); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.38], N[Not[LessEqual[x, 1.4]], $MachinePrecision]], N[(1.0 / N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.38 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot -0.6666666666666666\\
\end{array}
\end{array}
if x < -0.38 or 1.3999999999999999 < x Initial program 6.0%
flip3--6.0%
div-inv6.0%
rem-cube-cbrt6.1%
rem-cube-cbrt7.0%
cbrt-unprod7.0%
pow27.0%
distribute-rgt-out7.0%
+-commutative7.0%
Applied egg-rr7.0%
associate-*r/7.0%
*-rgt-identity7.0%
+-commutative7.0%
associate--l+50.1%
+-inverses50.1%
metadata-eval50.1%
+-commutative50.1%
fma-def50.1%
+-commutative50.1%
+-commutative50.1%
Simplified50.1%
pow1/347.9%
pow-pow45.6%
metadata-eval45.6%
Applied egg-rr45.6%
Taylor expanded in x around inf 11.0%
unpow1/311.0%
unpow211.0%
Simplified11.0%
cbrt-div11.0%
metadata-eval11.0%
cbrt-prod17.7%
pow217.7%
Applied egg-rr17.7%
if -0.38 < x < 1.3999999999999999Initial program 100.0%
flip3--99.8%
div-inv99.8%
rem-cube-cbrt99.8%
rem-cube-cbrt99.8%
cbrt-unprod99.9%
pow299.9%
distribute-rgt-out99.9%
+-commutative99.9%
Applied egg-rr99.9%
associate-*r/99.9%
*-rgt-identity99.9%
+-commutative99.9%
associate--l+99.8%
+-inverses99.8%
metadata-eval99.8%
+-commutative99.8%
fma-def99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 92.1%
*-commutative92.1%
Simplified92.1%
Final simplification53.5%
(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 51.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 51.1%
Taylor expanded in x around 0 47.5%
Final simplification47.5%
herbie shell --seed 2023174
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))