
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) {
return cbrt((x + 1.0)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((x + 1.0)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x + 1} - \sqrt[3]{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) {
return cbrt((x + 1.0)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((x + 1.0)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x + 1} - \sqrt[3]{x}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (pow t_0 2.0)))
(/
(+ 1.0 (- x x))
(fma (cbrt x) (+ (cbrt x) (* (cbrt t_1) (cbrt t_0))) t_1))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = pow(t_0, 2.0);
return (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + (cbrt(t_1) * cbrt(t_0))), t_1);
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = t_0 ^ 2.0 return Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + Float64(cbrt(t_1) * cbrt(t_0))), t_1)) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(N[Power[t$95$1, 1/3], $MachinePrecision] * N[Power[t$95$0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := {t_0}^{2}\\
\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{t_1} \cdot \sqrt[3]{t_0}, t_1\right)}
\end{array}
\end{array}
Initial program 55.4%
add-exp-log55.4%
Applied egg-rr55.4%
Applied egg-rr55.5%
div-sub56.9%
+-commutative56.9%
associate--l+99.2%
+-commutative99.2%
fma-def99.2%
+-commutative99.2%
+-commutative99.2%
Simplified99.2%
+-commutative99.2%
add-cbrt-cube99.2%
cbrt-prod99.2%
pow299.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) t_1 (cbrt (pow x 2.0))))
(/ (- (+ 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 / fma(cbrt(x), t_1, cbrt(pow(x, 2.0)));
} else {
tmp = ((1.0 + x) - x) / (pow(t_0, 2.0) + (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 / fma(cbrt(x), t_1, cbrt((x ^ 2.0)))); 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] * t$95$1 + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $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}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, \sqrt[3]{{x}^{2}}\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.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+48.5%
+-inverses48.5%
metadata-eval48.5%
+-commutative48.5%
exp-prod48.0%
Simplified48.0%
Taylor expanded in x around inf 42.1%
unpow1/344.0%
Simplified44.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.0%
add-exp-log97.0%
Applied egg-rr97.0%
rem-exp-log97.0%
add-sqr-sqrt43.5%
cbrt-prod43.5%
pow1/343.5%
sqrt-pow243.5%
metadata-eval43.5%
flip3--43.8%
Applied egg-rr99.8%
Final simplification74.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (* (cbrt x) (+ (cbrt x) t_0))))
(if (<= (- t_0 (cbrt x)) 0.0)
(exp (- (log1p t_1)))
(/ (- (+ 1.0 x) x) (+ (pow t_0 2.0) t_1)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) * (cbrt(x) + t_0);
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = exp(-log1p(t_1));
} else {
tmp = ((1.0 + x) - x) / (pow(t_0, 2.0) + t_1);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = Math.cbrt(x) * (Math.cbrt(x) + t_0);
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = Math.exp(-Math.log1p(t_1));
} else {
tmp = ((1.0 + x) - x) / (Math.pow(t_0, 2.0) + t_1);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) * Float64(cbrt(x) + t_0)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = exp(Float64(-log1p(t_1))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64((t_0 ^ 2.0) + 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] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[Exp[(-N[Log[1 + t$95$1], $MachinePrecision])], $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;e^{-\mathsf{log1p}\left(t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{{t_0}^{2} + t_1}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+48.5%
+-inverses48.5%
metadata-eval48.5%
+-commutative48.5%
exp-prod48.0%
Simplified48.0%
Taylor expanded in x around 0 19.9%
add-exp-log19.9%
log-rec19.9%
fma-udef19.9%
+-commutative19.9%
log1p-udef19.9%
+-commutative19.9%
Applied egg-rr19.9%
+-commutative19.9%
Simplified19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.0%
add-exp-log97.0%
Applied egg-rr97.0%
rem-exp-log97.0%
add-sqr-sqrt43.5%
cbrt-prod43.5%
pow1/343.5%
sqrt-pow243.5%
metadata-eval43.5%
flip3--43.8%
Applied egg-rr99.8%
Final simplification63.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(exp (- (log1p (* (cbrt x) (+ (cbrt x) t_0)))))
(- (/ (cbrt (+ 1.0 (pow x 3.0))) (cbrt (- (fma x x 1.0) x))) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = exp(-log1p((cbrt(x) * (cbrt(x) + t_0))));
} else {
tmp = (cbrt((1.0 + pow(x, 3.0))) / cbrt((fma(x, x, 1.0) - x))) - cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = exp(Float64(-log1p(Float64(cbrt(x) * Float64(cbrt(x) + t_0))))); else tmp = Float64(Float64(cbrt(Float64(1.0 + (x ^ 3.0))) / cbrt(Float64(fma(x, x, 1.0) - x))) - cbrt(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[Exp[(-N[Log[1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], N[(N[(N[Power[N[(1.0 + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(N[(x * x + 1.0), $MachinePrecision] - x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;e^{-\mathsf{log1p}\left(\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 + {x}^{3}}}{\sqrt[3]{\mathsf{fma}\left(x, x, 1\right) - x}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+48.5%
+-inverses48.5%
metadata-eval48.5%
+-commutative48.5%
exp-prod48.0%
Simplified48.0%
Taylor expanded in x around 0 19.9%
add-exp-log19.9%
log-rec19.9%
fma-udef19.9%
+-commutative19.9%
log1p-udef19.9%
+-commutative19.9%
Applied egg-rr19.9%
+-commutative19.9%
Simplified19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.0%
flip3-+97.0%
cbrt-div97.0%
pow397.0%
metadata-eval97.0%
+-commutative97.0%
pow397.0%
metadata-eval97.0%
*-rgt-identity97.0%
associate-+r-97.0%
fma-def97.0%
Applied egg-rr97.0%
Final simplification62.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x))))
(if (<= t_1 0.0)
(exp (- (log1p (* (cbrt x) (+ (cbrt x) t_0)))))
(pow (pow t_1 3.0) 0.3333333333333333))))
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 = exp(-log1p((cbrt(x) * (cbrt(x) + t_0))));
} else {
tmp = pow(pow(t_1, 3.0), 0.3333333333333333);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 0.0) {
tmp = Math.exp(-Math.log1p((Math.cbrt(x) * (Math.cbrt(x) + t_0))));
} else {
tmp = Math.pow(Math.pow(t_1, 3.0), 0.3333333333333333);
}
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 = exp(Float64(-log1p(Float64(cbrt(x) * Float64(cbrt(x) + t_0))))); else tmp = (t_1 ^ 3.0) ^ 0.3333333333333333; 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[Exp[(-N[Log[1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 0.3333333333333333], $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:\\
\;\;\;\;e^{-\mathsf{log1p}\left(\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left({t_1}^{3}\right)}^{0.3333333333333333}\\
\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%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+48.5%
+-inverses48.5%
metadata-eval48.5%
+-commutative48.5%
exp-prod48.0%
Simplified48.0%
Taylor expanded in x around 0 19.9%
add-exp-log19.9%
log-rec19.9%
fma-udef19.9%
+-commutative19.9%
log1p-udef19.9%
+-commutative19.9%
Applied egg-rr19.9%
+-commutative19.9%
Simplified19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.0%
add-cbrt-cube96.9%
pow1/397.0%
pow397.0%
Applied egg-rr97.0%
Final simplification62.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(/ 1.0 (+ 1.0 (* (cbrt x) t_0)))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (pow x 2.0))))
(/ 1.0 (fma (cbrt x) t_0 (exp (* (log1p 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 / (1.0 + (cbrt(x) * t_0));
} else if (x <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt(pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, exp((log1p(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 / Float64(1.0 + Float64(cbrt(x) * t_0))); elseif (x <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt((x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, exp(Float64(log1p(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[(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[Power[x, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Exp[N[(N[Log[1 + x], $MachinePrecision] * 0.6666666666666666), $MachinePrecision]], $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}{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}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, e^{\mathsf{log1p}\left(x\right) \cdot 0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1.35000000000000003e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.5%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-def4.7%
add-exp-log4.7%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
+-commutative0.0%
associate--l+0.0%
+-inverses0.0%
metadata-eval0.0%
+-commutative0.0%
exp-prod0.0%
Simplified0.0%
Taylor expanded in x around 0 19.9%
fma-udef19.9%
+-commutative19.9%
Applied egg-rr19.9%
if -1.35000000000000003e154 < x < -1Initial program 16.5%
flip3--17.8%
div-inv17.8%
rem-cube-cbrt17.6%
rem-cube-cbrt23.8%
+-commutative23.8%
distribute-rgt-out23.8%
+-commutative23.8%
fma-def23.8%
add-exp-log23.6%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
+-commutative0.0%
associate--l+0.0%
+-inverses0.0%
metadata-eval0.0%
+-commutative0.0%
exp-prod0.0%
Simplified0.0%
Taylor expanded in x around inf 86.3%
unpow1/389.9%
Simplified89.9%
if -1 < x Initial program 69.5%
flip3--69.5%
div-inv69.5%
rem-cube-cbrt69.3%
rem-cube-cbrt70.3%
+-commutative70.3%
distribute-rgt-out70.3%
+-commutative70.3%
fma-def70.3%
add-exp-log70.3%
Applied egg-rr70.3%
associate-*r/70.3%
*-rgt-identity70.3%
+-commutative70.3%
associate--l+97.7%
+-inverses97.7%
metadata-eval97.7%
+-commutative97.7%
exp-prod97.4%
Simplified97.4%
add-exp-log97.5%
log-pow97.7%
rem-log-exp97.7%
Applied egg-rr97.7%
Final simplification87.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x))))
(if (<= t_1 0.0)
(/ 1.0 (+ 1.0 (* (cbrt x) (+ (cbrt x) t_0))))
(pow (pow t_1 3.0) 0.3333333333333333))))
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 / (1.0 + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = pow(pow(t_1, 3.0), 0.3333333333333333);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 0.0) {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
} else {
tmp = Math.pow(Math.pow(t_1, 3.0), 0.3333333333333333);
}
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 / Float64(1.0 + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); else tmp = (t_1 ^ 3.0) ^ 0.3333333333333333; 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[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 0.3333333333333333], $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}{1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left({t_1}^{3}\right)}^{0.3333333333333333}\\
\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%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+48.5%
+-inverses48.5%
metadata-eval48.5%
+-commutative48.5%
exp-prod48.0%
Simplified48.0%
Taylor expanded in x around 0 19.9%
fma-udef19.9%
+-commutative19.9%
Applied egg-rr19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.0%
add-cbrt-cube96.9%
pow1/397.0%
pow397.0%
Applied egg-rr97.0%
Final simplification62.4%
(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 55.4%
pow1/352.0%
Applied egg-rr52.0%
pow1/355.4%
flip3--55.5%
div-inv55.5%
rem-cube-cbrt55.2%
rem-cube-cbrt56.9%
unpow256.9%
+-commutative56.9%
distribute-rgt-in56.9%
Applied egg-rr56.9%
associate-*r/56.9%
*-rgt-identity56.9%
+-commutative56.9%
associate--l+99.2%
+-inverses99.2%
metadata-eval99.2%
+-commutative99.2%
fma-def99.2%
+-commutative99.2%
+-commutative99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x)))) (if (<= t_1 0.0) (/ 1.0 (+ 1.0 (* (cbrt x) (+ (cbrt x) t_0)))) t_1)))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 0.0) {
tmp = 1.0 / (1.0 + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 0.0) {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); else tmp = t_1; end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-def4.2%
add-exp-log4.2%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+48.5%
+-inverses48.5%
metadata-eval48.5%
+-commutative48.5%
exp-prod48.0%
Simplified48.0%
Taylor expanded in x around 0 19.9%
fma-udef19.9%
+-commutative19.9%
Applied egg-rr19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.0%
Final simplification62.4%
(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 55.4%
Final simplification55.4%
(FPCore (x) :precision binary64 (- (+ 1.0 (* x (+ 0.3333333333333333 (* x -0.1111111111111111)))) (cbrt x)))
double code(double x) {
return (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - cbrt(x);
}
public static double code(double x) {
return (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - Math.cbrt(x);
}
function code(x) return Float64(Float64(1.0 + Float64(x * Float64(0.3333333333333333 + Float64(x * -0.1111111111111111)))) - cbrt(x)) end
code[x_] := N[(N[(1.0 + N[(x * N[(0.3333333333333333 + N[(x * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + x \cdot \left(0.3333333333333333 + x \cdot -0.1111111111111111\right)\right) - \sqrt[3]{x}
\end{array}
Initial program 55.4%
pow1/352.0%
Applied egg-rr52.0%
Taylor expanded in x around 0 51.5%
*-commutative51.5%
unpow251.5%
associate-*l*51.5%
*-commutative51.5%
distribute-lft-out51.5%
Simplified51.5%
Final simplification51.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 55.4%
Taylor expanded in x around inf 3.6%
Final simplification3.6%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 55.4%
Taylor expanded in x around 0 50.1%
Final simplification50.1%
herbie shell --seed 2023322
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))