
(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 15 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 (/ 1.0 (cbrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (/ 1.0 t_0)) (/ 1.0 (* t_0 t_0))))))
double code(double x) {
double t_0 = 1.0 / cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + (1.0 / t_0)), (1.0 / (t_0 * t_0)));
}
function code(x) t_0 = Float64(1.0 / cbrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(1.0 / t_0)), Float64(1.0 / Float64(t_0 * t_0)))) end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt[3]{1 + x}}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \frac{1}{t_0}, \frac{1}{t_0 \cdot t_0}\right)}
\end{array}
\end{array}
Initial program 57.5%
flip3--57.4%
div-inv57.4%
rem-cube-cbrt57.3%
rem-cube-cbrt59.1%
cbrt-unprod59.1%
pow259.1%
distribute-rgt-out59.1%
+-commutative59.1%
Applied egg-rr59.1%
associate-*r/59.1%
*-rgt-identity59.1%
+-commutative59.1%
associate--l+77.7%
+-inverses77.7%
metadata-eval77.7%
+-commutative77.7%
fma-def77.7%
+-commutative77.7%
+-commutative77.7%
Simplified77.7%
Applied egg-rr99.3%
+-commutative99.3%
flip-+77.6%
metadata-eval77.6%
fma-neg77.6%
metadata-eval77.6%
sub-neg77.6%
metadata-eval77.6%
rem-cube-cbrt77.6%
cbrt-undiv77.7%
pow377.7%
add-cbrt-cube77.7%
clear-num77.7%
clear-num77.7%
add-cbrt-cube77.7%
pow377.7%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))
(fma (cbrt (- 1.0 (* x x))) (/ 1.0 (cbrt (- 1.0 x))) (- (cbrt x))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
} else {
tmp = fma(cbrt((1.0 - (x * x))), (1.0 / cbrt((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-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); else tmp = fma(cbrt(Float64(1.0 - Float64(x * x))), Float64(1.0 / cbrt(Float64(1.0 - x))), Float64(-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-11], 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[(N[Power[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(1.0 / N[Power[N[(1.0 - 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^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{1 - x \cdot x}, \frac{1}{\sqrt[3]{1 - x}}, -\sqrt[3]{x}\right)\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt5.9%
cbrt-unprod5.9%
pow25.9%
distribute-rgt-out5.9%
+-commutative5.9%
Applied egg-rr5.9%
associate-*r/5.9%
*-rgt-identity5.9%
+-commutative5.9%
associate--l+48.7%
+-inverses48.7%
metadata-eval48.7%
+-commutative48.7%
fma-def48.8%
+-commutative48.8%
+-commutative48.8%
Simplified48.8%
Taylor expanded in x around 0 20.0%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.1%
pow1/397.7%
Applied egg-rr97.7%
pow1/398.1%
+-commutative98.1%
flip-+98.2%
cbrt-div98.2%
metadata-eval98.2%
Applied egg-rr98.2%
div-inv98.2%
fma-neg98.2%
Applied egg-rr98.2%
Final simplification64.3%
(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 57.5%
flip3--57.4%
div-inv57.4%
rem-cube-cbrt57.3%
rem-cube-cbrt59.1%
cbrt-unprod59.1%
pow259.1%
distribute-rgt-out59.1%
+-commutative59.1%
Applied egg-rr59.1%
associate-*r/59.1%
*-rgt-identity59.1%
+-commutative59.1%
associate--l+77.7%
+-inverses77.7%
metadata-eval77.7%
+-commutative77.7%
fma-def77.7%
+-commutative77.7%
+-commutative77.7%
Simplified77.7%
unpow277.7%
+-commutative77.7%
+-commutative77.7%
add-cube-cbrt77.7%
add-cube-cbrt77.6%
swap-sqr77.6%
add-cbrt-cube99.3%
pow299.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (/ 1.0 (pow (/ 1.0 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((1.0 / 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 / (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[N[(1.0 / t$95$0), $MachinePrecision], 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}{{\left(\frac{1}{t_0}\right)}^{2}}\right)}
\end{array}
\end{array}
Initial program 57.5%
flip3--57.4%
div-inv57.4%
rem-cube-cbrt57.3%
rem-cube-cbrt59.1%
cbrt-unprod59.1%
pow259.1%
distribute-rgt-out59.1%
+-commutative59.1%
Applied egg-rr59.1%
associate-*r/59.1%
*-rgt-identity59.1%
+-commutative59.1%
associate--l+77.7%
+-inverses77.7%
metadata-eval77.7%
+-commutative77.7%
fma-def77.7%
+-commutative77.7%
+-commutative77.7%
Simplified77.7%
Applied egg-rr99.3%
pow299.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))
(- (/ (cbrt (- 1.0 (* x x))) (cbrt (- 1.0 x))) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
} else {
tmp = (cbrt((1.0 - (x * x))) / cbrt((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-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); else tmp = Float64(Float64(cbrt(Float64(1.0 - Float64(x * x))) / cbrt(Float64(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-11], 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[(N[(N[Power[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(1.0 - 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^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 - x \cdot x}}{\sqrt[3]{1 - x}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.9%
rem-cube-cbrt5.9%
cbrt-unprod5.9%
pow25.9%
distribute-rgt-out5.9%
+-commutative5.9%
Applied egg-rr5.9%
associate-*r/5.9%
*-rgt-identity5.9%
+-commutative5.9%
associate--l+48.7%
+-inverses48.7%
metadata-eval48.7%
+-commutative48.7%
fma-def48.8%
+-commutative48.8%
+-commutative48.8%
Simplified48.8%
Taylor expanded in x around 0 20.0%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.1%
pow1/397.7%
Applied egg-rr97.7%
pow1/398.1%
+-commutative98.1%
flip-+98.2%
cbrt-div98.2%
metadata-eval98.2%
Applied egg-rr98.2%
Final simplification64.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 57.5%
flip3--57.4%
div-inv57.4%
rem-cube-cbrt57.3%
rem-cube-cbrt59.1%
cbrt-unprod59.1%
pow259.1%
distribute-rgt-out59.1%
+-commutative59.1%
Applied egg-rr59.1%
associate-*r/59.1%
*-rgt-identity59.1%
+-commutative59.1%
associate--l+77.7%
+-inverses77.7%
metadata-eval77.7%
+-commutative77.7%
fma-def77.7%
+-commutative77.7%
+-commutative77.7%
Simplified77.7%
Applied egg-rr97.3%
expm1-def97.3%
expm1-log1p99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(/ 1.0 (fma (cbrt x) t_0 1.0))
(if (<= x 1.4e+154)
(/
1.0
(+ (cbrt (pow (+ 1.0 x) 2.0)) (+ (cbrt (* x x)) (cbrt (fma x 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.35e+154) {
tmp = 1.0 / fma(cbrt(x), t_0, 1.0);
} else if (x <= 1.4e+154) {
tmp = 1.0 / (cbrt(pow((1.0 + x), 2.0)) + (cbrt((x * x)) + cbrt(fma(x, 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.35e+154) tmp = Float64(1.0 / fma(cbrt(x), t_0, 1.0)); elseif (x <= 1.4e+154) tmp = Float64(1.0 / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(Float64(x * x)) + cbrt(fma(x, 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.35e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(1.0 / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(x * x + x), $MachinePrecision], 1/3], $MachinePrecision]), $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.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \left(\sqrt[3]{x \cdot x} + \sqrt[3]{\mathsf{fma}\left(x, x, x\right)}\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.35000000000000003e154Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.7%
rem-cube-cbrt4.8%
cbrt-unprod4.8%
pow24.8%
distribute-rgt-out4.8%
+-commutative4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+4.8%
+-inverses4.8%
metadata-eval4.8%
+-commutative4.8%
fma-def4.8%
+-commutative4.8%
+-commutative4.8%
Simplified4.8%
Taylor expanded in x around 0 20.0%
if -1.35000000000000003e154 < x < 1.4e154Initial program 73.2%
flip3--73.2%
div-inv73.2%
rem-cube-cbrt73.4%
rem-cube-cbrt75.4%
cbrt-unprod75.4%
pow275.4%
distribute-rgt-out75.4%
+-commutative75.4%
Applied egg-rr75.4%
associate-*r/75.4%
*-rgt-identity75.4%
+-commutative75.4%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
fma-def99.5%
+-commutative99.5%
+-commutative99.5%
Simplified99.5%
unpow299.5%
+-commutative99.5%
+-commutative99.5%
add-cube-cbrt99.5%
add-cube-cbrt99.4%
swap-sqr99.4%
add-cbrt-cube99.4%
pow299.4%
Applied egg-rr99.5%
fma-udef99.5%
+-commutative99.5%
+-commutative99.5%
distribute-rgt-in99.4%
div-inv99.4%
+-commutative99.4%
remove-double-div99.4%
+-commutative99.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
associate-+r+99.4%
Applied egg-rr99.7%
associate-+l+99.7%
+-commutative99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.3%
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%
pow1/34.7%
pow-pow91.6%
metadata-eval91.6%
Applied egg-rr91.6%
Final simplification90.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(/ 1.0 (fma (cbrt x) t_0 1.0))
(if (<= x 1.4e+154)
(/
1.0
(+ (+ (cbrt (pow (+ 1.0 x) 2.0)) (cbrt (* x x))) (cbrt (+ x (* 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.35e+154) {
tmp = 1.0 / fma(cbrt(x), t_0, 1.0);
} else if (x <= 1.4e+154) {
tmp = 1.0 / ((cbrt(pow((1.0 + x), 2.0)) + cbrt((x * x))) + cbrt((x + (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.35e+154) tmp = Float64(1.0 / fma(cbrt(x), t_0, 1.0)); elseif (x <= 1.4e+154) tmp = Float64(1.0 / Float64(Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + cbrt(Float64(x * x))) + cbrt(Float64(x + 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.35e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(1.0 / N[(N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(x + N[(x * x), $MachinePrecision]), $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.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x \cdot x}\right) + \sqrt[3]{x + x \cdot x}}\\
\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.35000000000000003e154Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.7%
rem-cube-cbrt4.8%
cbrt-unprod4.8%
pow24.8%
distribute-rgt-out4.8%
+-commutative4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+4.8%
+-inverses4.8%
metadata-eval4.8%
+-commutative4.8%
fma-def4.8%
+-commutative4.8%
+-commutative4.8%
Simplified4.8%
Taylor expanded in x around 0 20.0%
if -1.35000000000000003e154 < x < 1.4e154Initial program 73.2%
flip3--73.2%
div-inv73.2%
rem-cube-cbrt73.4%
rem-cube-cbrt75.4%
cbrt-unprod75.4%
pow275.4%
distribute-rgt-out75.4%
+-commutative75.4%
Applied egg-rr75.4%
associate-*r/75.4%
*-rgt-identity75.4%
+-commutative75.4%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
fma-def99.5%
+-commutative99.5%
+-commutative99.5%
Simplified99.5%
unpow299.5%
+-commutative99.5%
+-commutative99.5%
add-cube-cbrt99.5%
add-cube-cbrt99.4%
swap-sqr99.4%
add-cbrt-cube99.4%
pow299.4%
Applied egg-rr99.5%
fma-udef99.5%
+-commutative99.5%
+-commutative99.5%
distribute-rgt-in99.4%
div-inv99.4%
+-commutative99.4%
remove-double-div99.4%
+-commutative99.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
associate-+r+99.4%
Applied egg-rr99.7%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.3%
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%
pow1/34.7%
pow-pow91.6%
metadata-eval91.6%
Applied egg-rr91.6%
Final simplification90.3%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (pow t_0 2.0) (* (cbrt x) (+ (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / (pow(t_0, 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + 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[t$95$0, 2.0], $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}\\
\frac{1}{{t_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}
\end{array}
\end{array}
Initial program 57.5%
flip3--57.4%
div-inv57.4%
rem-cube-cbrt57.3%
rem-cube-cbrt59.1%
cbrt-unprod59.1%
pow259.1%
distribute-rgt-out59.1%
+-commutative59.1%
Applied egg-rr59.1%
associate-*r/59.1%
*-rgt-identity59.1%
+-commutative59.1%
associate--l+77.7%
+-inverses77.7%
metadata-eval77.7%
+-commutative77.7%
fma-def77.7%
+-commutative77.7%
+-commutative77.7%
Simplified77.7%
fma-udef77.7%
pow1/376.8%
unpow276.8%
pow-prod-down76.5%
+-commutative76.5%
pow1/376.8%
+-commutative76.8%
pow1/399.2%
+-commutative99.2%
pow299.2%
+-commutative99.2%
pow1/349.1%
*-commutative49.1%
pow1/399.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(if (or (<= x -1.35e+154) (not (<= x 1.4e+154)))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))
(/
1.0
(+ (+ (cbrt (pow (+ 1.0 x) 2.0)) (cbrt (* x x))) (cbrt (+ x (* x x)))))))
double code(double x) {
double tmp;
if ((x <= -1.35e+154) || !(x <= 1.4e+154)) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
} else {
tmp = 1.0 / ((cbrt(pow((1.0 + x), 2.0)) + cbrt((x * x))) + cbrt((x + (x * x))));
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.35e+154) || !(x <= 1.4e+154)) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); else tmp = Float64(1.0 / Float64(Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + cbrt(Float64(x * x))) + cbrt(Float64(x + Float64(x * x))))); end return tmp end
code[x_] := If[Or[LessEqual[x, -1.35e+154], N[Not[LessEqual[x, 1.4e+154]], $MachinePrecision]], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+154} \lor \neg \left(x \leq 1.4 \cdot 10^{+154}\right):\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x \cdot x}\right) + \sqrt[3]{x + x \cdot x}}\\
\end{array}
\end{array}
if x < -1.35000000000000003e154 or 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.5%
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 20.0%
if -1.35000000000000003e154 < x < 1.4e154Initial program 73.2%
flip3--73.2%
div-inv73.2%
rem-cube-cbrt73.4%
rem-cube-cbrt75.4%
cbrt-unprod75.4%
pow275.4%
distribute-rgt-out75.4%
+-commutative75.4%
Applied egg-rr75.4%
associate-*r/75.4%
*-rgt-identity75.4%
+-commutative75.4%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
fma-def99.5%
+-commutative99.5%
+-commutative99.5%
Simplified99.5%
unpow299.5%
+-commutative99.5%
+-commutative99.5%
add-cube-cbrt99.5%
add-cube-cbrt99.4%
swap-sqr99.4%
add-cbrt-cube99.4%
pow299.4%
Applied egg-rr99.5%
fma-udef99.5%
+-commutative99.5%
+-commutative99.5%
distribute-rgt-in99.4%
div-inv99.4%
+-commutative99.4%
remove-double-div99.4%
+-commutative99.4%
unpow299.4%
+-commutative99.4%
unpow299.4%
associate-+r+99.4%
Applied egg-rr99.7%
Final simplification81.3%
(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 57.5%
Final simplification57.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 57.5%
add-cube-cbrt57.3%
pow357.3%
Applied egg-rr57.3%
Taylor expanded in x around 0 28.0%
associate--l+28.0%
*-commutative28.0%
metadata-eval28.0%
pow-base-128.0%
unpow1/355.6%
*-lft-identity55.6%
Simplified55.6%
Final simplification55.6%
(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 57.5%
add-cube-cbrt57.3%
pow357.3%
Applied egg-rr57.3%
Taylor expanded in x around 0 27.0%
metadata-eval27.0%
pow-base-127.0%
unpow1/355.4%
*-lft-identity55.4%
Simplified55.4%
Final simplification55.4%
(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 57.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 57.5%
Taylor expanded in x around 0 53.5%
Final simplification53.5%
herbie shell --seed 2023222
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))