
(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))))
(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))
(+ (pow (cbrt x) 2.0) (cbrt (* x (+ 1.0 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), (cbrt(x) + cbrt(x)), pow(t_0, 2.0));
} else {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (pow(cbrt(x), 2.0) + cbrt((x * (1.0 + 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(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) ^ 2.0) + cbrt(Float64(x * Float64(1.0 + 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[(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[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision], 1/3], $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}} + \left({\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x \cdot \left(1 + x\right)}\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.4%
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+52.8%
+-inverses52.8%
metadata-eval52.8%
+-commutative52.8%
fma-def52.8%
+-commutative52.8%
+-commutative52.8%
Simplified52.8%
pow1/350.4%
+-commutative50.4%
unpow250.4%
pow-prod-down47.5%
+-commutative47.5%
pow1/348.4%
+-commutative48.4%
pow1/398.4%
Applied egg-rr98.4%
unpow298.4%
Simplified98.4%
+-commutative98.4%
rem-cube-cbrt98.2%
+-commutative98.2%
Applied egg-rr98.2%
Taylor expanded in x around inf 48.4%
unpow1/398.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.3%
flip3--99.6%
rem-cube-cbrt99.1%
rem-cube-cbrt99.8%
cbrt-unprod99.9%
pow299.9%
distribute-rgt-out99.9%
+-commutative99.9%
Applied egg-rr99.9%
distribute-rgt-in99.9%
+-commutative99.9%
pow299.9%
cbrt-unprod99.9%
*-commutative99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-7)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (cbrt (* x x))))
(+ (pow (+ 1.0 x) 0.3333333333333333) (- (cbrt x))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-7) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), cbrt((x * x)));
} else {
tmp = pow((1.0 + x), 0.3333333333333333) + -cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-7) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), cbrt(Float64(x * x)))); else tmp = Float64((Float64(1.0 + x) ^ 0.3333333333333333) + 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-7], 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[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $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^{-7}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \sqrt[3]{x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(1 + x\right)}^{0.3333333333333333} + \left(-\sqrt[3]{x}\right)\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.99999999999999977e-7Initial program 5.0%
flip3--5.3%
div-inv5.3%
rem-cube-cbrt4.2%
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+53.5%
+-inverses53.5%
metadata-eval53.5%
+-commutative53.5%
fma-def53.5%
+-commutative53.5%
+-commutative53.5%
Simplified53.5%
pow1/351.1%
+-commutative51.1%
unpow251.1%
pow-prod-down47.6%
pow-prod-up47.6%
+-commutative47.6%
metadata-eval47.6%
Applied egg-rr47.6%
Taylor expanded in x around inf 50.6%
unpow1/353.0%
unpow253.0%
Simplified53.0%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 100.0%
pow1/3100.0%
Applied egg-rr100.0%
Final simplification75.9%
(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.4%
flip3--51.5%
div-inv51.5%
rem-cube-cbrt50.9%
rem-cube-cbrt51.6%
cbrt-unprod51.7%
pow251.7%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+76.1%
+-inverses76.1%
metadata-eval76.1%
+-commutative76.1%
fma-def76.1%
+-commutative76.1%
+-commutative76.1%
Simplified76.1%
pow1/374.9%
+-commutative74.9%
unpow274.9%
pow-prod-down73.1%
+-commutative73.1%
pow1/373.5%
+-commutative73.5%
pow1/399.1%
Applied egg-rr99.1%
unpow299.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (exp (- (log (pow (cbrt x) 2.0)))) (exp (log t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = exp(-log(pow(cbrt(x), 2.0)));
} else {
tmp = exp(log(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 = Math.exp(-Math.log(Math.pow(Math.cbrt(x), 2.0)));
} else {
tmp = Math.exp(Math.log(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 = exp(Float64(-log((cbrt(x) ^ 2.0)))); else tmp = exp(log(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[Exp[(-N[Log[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision])], $MachinePrecision], N[Exp[N[Log[t$95$0], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;e^{-\log \left({\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\log 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.4%
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+52.8%
+-inverses52.8%
metadata-eval52.8%
+-commutative52.8%
fma-def52.8%
+-commutative52.8%
+-commutative52.8%
Simplified52.8%
pow1/350.4%
+-commutative50.4%
unpow250.4%
pow-prod-down47.5%
pow-prod-up47.5%
+-commutative47.5%
metadata-eval47.5%
Applied egg-rr47.5%
Taylor expanded in x around inf 11.4%
unpow1/311.4%
unpow211.4%
Simplified11.4%
cbrt-div11.4%
metadata-eval11.4%
inv-pow11.4%
add-exp-log11.4%
pow-exp11.4%
cbrt-prod17.7%
pow217.7%
Applied egg-rr17.7%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.3%
add-exp-log99.3%
Applied egg-rr99.3%
Final simplification58.2%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (exp (- (log (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 = exp(-log(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 = Math.exp(-Math.log(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 = exp(Float64(-log((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[Exp[(-N[Log[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $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:\\
\;\;\;\;e^{-\log \left({\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\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.4%
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+52.8%
+-inverses52.8%
metadata-eval52.8%
+-commutative52.8%
fma-def52.8%
+-commutative52.8%
+-commutative52.8%
Simplified52.8%
pow1/350.4%
+-commutative50.4%
unpow250.4%
pow-prod-down47.5%
pow-prod-up47.5%
+-commutative47.5%
metadata-eval47.5%
Applied egg-rr47.5%
Taylor expanded in x around inf 11.4%
unpow1/311.4%
unpow211.4%
Simplified11.4%
cbrt-div11.4%
metadata-eval11.4%
inv-pow11.4%
add-exp-log11.4%
pow-exp11.4%
cbrt-prod17.7%
pow217.7%
Applied egg-rr17.7%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.3%
Final simplification58.2%
(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.35e+154)
(/ (+ 1.0 (- x x)) (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) t_0)))
(/ 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.35e+154) {
tmp = (1.0 + (x - x)) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * t_0));
} 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.35e+154) tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * t_0))); 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.35e+154], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $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.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t_0}\\
\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.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%
Taylor expanded in x around 0 19.9%
if -1.35000000000000003e154 < x < 1.35000000000000003e154Initial program 66.6%
flip3--66.7%
rem-cube-cbrt66.5%
rem-cube-cbrt66.9%
cbrt-unprod67.0%
pow267.0%
distribute-rgt-out67.0%
+-commutative67.0%
Applied egg-rr67.0%
+-commutative67.0%
associate--l+99.5%
Applied egg-rr99.5%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt2.8%
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%
pow1/34.8%
+-commutative4.8%
unpow24.8%
pow-prod-down91.6%
pow-prod-up91.6%
+-commutative91.6%
metadata-eval91.6%
Applied egg-rr91.6%
Final simplification88.6%
(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.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.35e+154) {
tmp = 1.0 / fma(cbrt(x), t_0, 1.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.35e+154) tmp = Float64(1.0 / fma(cbrt(x), t_0, 1.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.35e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $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.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\
\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.35000000000000003e154Initial 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%
Taylor expanded in x around 0 19.9%
if -1.35000000000000003e154 < x < -1Initial program 5.5%
flip3--6.7%
div-inv6.7%
rem-cube-cbrt6.0%
rem-cube-cbrt6.7%
cbrt-unprod6.7%
pow26.7%
distribute-rgt-out6.6%
+-commutative6.6%
Applied egg-rr6.6%
associate-*r/6.6%
*-rgt-identity6.6%
+-commutative6.6%
associate--l+98.8%
+-inverses98.8%
metadata-eval98.8%
+-commutative98.8%
fma-def98.7%
+-commutative98.7%
+-commutative98.7%
Simplified98.7%
pow1/393.9%
+-commutative93.9%
unpow293.9%
pow-prod-down0.0%
pow-prod-up0.0%
+-commutative0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 92.9%
unpow1/397.7%
unpow297.7%
Simplified97.7%
if -1 < x Initial program 66.8%
flip3--66.8%
div-inv66.8%
rem-cube-cbrt66.3%
rem-cube-cbrt66.9%
cbrt-unprod67.0%
pow267.0%
distribute-rgt-out67.0%
+-commutative67.0%
Applied egg-rr67.0%
associate-*r/67.0%
*-rgt-identity67.0%
+-commutative67.0%
associate--l+84.3%
+-inverses84.3%
metadata-eval84.3%
+-commutative84.3%
fma-def84.3%
+-commutative84.3%
+-commutative84.3%
Simplified84.3%
pow1/383.5%
+-commutative83.5%
unpow283.5%
pow-prod-down97.5%
pow-prod-up97.5%
+-commutative97.5%
metadata-eval97.5%
Applied egg-rr97.5%
Final simplification87.8%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (+ 1.0 (cbrt x)) (pow (cbrt (+ 1.0 x)) 2.0))))
double code(double x) {
return 1.0 / fma(cbrt(x), (1.0 + cbrt(x)), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(1.0 + cbrt(x)), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, 1 + \sqrt[3]{x}, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
Initial program 51.4%
flip3--51.5%
div-inv51.5%
rem-cube-cbrt50.9%
rem-cube-cbrt51.6%
cbrt-unprod51.7%
pow251.7%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+76.1%
+-inverses76.1%
metadata-eval76.1%
+-commutative76.1%
fma-def76.1%
+-commutative76.1%
+-commutative76.1%
Simplified76.1%
pow1/374.9%
+-commutative74.9%
unpow274.9%
pow-prod-down73.1%
+-commutative73.1%
pow1/373.5%
+-commutative73.5%
pow1/399.1%
Applied egg-rr99.1%
unpow299.1%
Simplified99.1%
+-commutative99.1%
rem-cube-cbrt99.0%
+-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in x around 0 58.3%
Final simplification58.3%
(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.4%
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+52.8%
+-inverses52.8%
metadata-eval52.8%
+-commutative52.8%
fma-def52.8%
+-commutative52.8%
+-commutative52.8%
Simplified52.8%
pow1/350.4%
+-commutative50.4%
unpow250.4%
pow-prod-down47.5%
pow-prod-up47.5%
+-commutative47.5%
metadata-eval47.5%
Applied egg-rr47.5%
Taylor expanded in x around inf 11.4%
unpow1/311.4%
unpow211.4%
Simplified11.4%
cbrt-div11.4%
metadata-eval11.4%
cbrt-prod17.7%
pow217.7%
Applied egg-rr17.7%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.3%
Final simplification58.2%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0)))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)) end
code[x_] := 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]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}
\end{array}
Initial program 51.4%
flip3--51.5%
div-inv51.5%
rem-cube-cbrt50.9%
rem-cube-cbrt51.6%
cbrt-unprod51.7%
pow251.7%
distribute-rgt-out51.6%
+-commutative51.6%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+76.1%
+-inverses76.1%
metadata-eval76.1%
+-commutative76.1%
fma-def76.1%
+-commutative76.1%
+-commutative76.1%
Simplified76.1%
Taylor expanded in x around 0 57.8%
Final simplification57.8%
(FPCore (x) :precision binary64 (if (or (<= x -0.96) (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.96) || !(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.96) || !(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.96) || !(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.96], 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.96 \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.95999999999999996 or 1.3999999999999999 < x Initial program 5.0%
flip3--5.3%
div-inv5.3%
rem-cube-cbrt4.2%
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+53.5%
+-inverses53.5%
metadata-eval53.5%
+-commutative53.5%
fma-def53.5%
+-commutative53.5%
+-commutative53.5%
Simplified53.5%
pow1/351.1%
+-commutative51.1%
unpow251.1%
pow-prod-down47.6%
pow-prod-up47.6%
+-commutative47.6%
metadata-eval47.6%
Applied egg-rr47.6%
Taylor expanded in x around inf 11.5%
unpow1/311.5%
unpow211.5%
Simplified11.5%
cbrt-div11.5%
metadata-eval11.5%
cbrt-prod17.7%
pow217.7%
Applied egg-rr17.7%
if -0.95999999999999996 < x < 1.3999999999999999Initial program 100.0%
flip3--99.9%
div-inv99.9%
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.9%
+-inverses99.9%
metadata-eval99.9%
+-commutative99.9%
fma-def99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 91.8%
*-commutative91.8%
Simplified91.8%
Final simplification53.9%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 51.4%
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.4%
Taylor expanded in x around 0 47.9%
Final simplification47.9%
herbie shell --seed 2023242
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))