
(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)) 4e-11)
(/
(+ 1.0 (- x x))
(*
x
(+ (cbrt (+ (/ 1.0 x) (/ 2.0 (pow x 2.0)))) (* 2.0 (cbrt (/ 1.0 x))))))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) t_0)
(exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 4e-11) {
tmp = (1.0 + (x - x)) / (x * (cbrt(((1.0 / x) + (2.0 / pow(x, 2.0)))) + (2.0 * cbrt((1.0 / x)))));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 4e-11) tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(cbrt(Float64(Float64(1.0 / x) + Float64(2.0 / (x ^ 2.0)))) + Float64(2.0 * cbrt(Float64(1.0 / x)))))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), exp(Float64(0.6666666666666666 * log1p(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], 4e-11], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Power[N[(N[(1.0 / x), $MachinePrecision] + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(2.0 * N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]), $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[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 4 \cdot 10^{-11}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt[3]{\frac{1}{x} + \frac{2}{{x}^{2}}} + 2 \cdot \sqrt[3]{\frac{1}{x}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) < 3.99999999999999976e-11Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.6%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+93.3%
+-commutative93.3%
+-commutative93.3%
Simplified93.3%
Taylor expanded in x around inf 93.3%
*-commutative93.3%
Simplified93.3%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
if 3.99999999999999976e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 61.4%
flip3--67.4%
div-inv67.4%
rem-cube-cbrt63.4%
rem-cube-cbrt98.4%
+-commutative98.4%
distribute-rgt-out98.2%
+-commutative98.2%
fma-define98.3%
add-exp-log98.2%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
+-commutative98.5%
associate--l+98.6%
+-commutative98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in x around 0 98.6%
Final simplification98.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (sqrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (pow (* t_0 t_0) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((t_0 * t_0), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(t_0 * t_0) ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision], 1/3], $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] + N[Power[N[(t$95$0 * t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt{1 + x}}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(t\_0 \cdot t\_0\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 6.7%
flip3--7.0%
div-inv7.0%
rem-cube-cbrt6.1%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.7%
associate-*r/8.7%
*-rgt-identity8.7%
+-commutative8.7%
associate--l+93.5%
+-commutative93.5%
+-commutative93.5%
Simplified93.5%
*-commutative93.5%
log1p-undefine93.5%
exp-to-pow93.0%
metadata-eval93.0%
pow-prod-up93.0%
+-commutative93.0%
pow1/394.5%
expm1-log1p-u94.7%
+-commutative94.7%
pow1/395.6%
expm1-log1p-u94.4%
pow294.4%
expm1-log1p-u98.4%
+-commutative98.4%
Applied egg-rr98.4%
pow1/393.0%
add-sqr-sqrt93.0%
unpow-prod-down93.0%
add-sqr-sqrt93.0%
hypot-1-def93.0%
add-sqr-sqrt93.0%
hypot-1-def93.0%
Applied egg-rr93.0%
unpow1/394.5%
hypot-undefine94.5%
metadata-eval94.5%
rem-square-sqrt94.5%
unpow1/398.5%
hypot-undefine98.5%
metadata-eval98.5%
rem-square-sqrt98.5%
Simplified98.5%
Taylor expanded in x around 0 98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 4e-11)
(/
(+ 1.0 (- x x))
(*
x
(+ (cbrt (+ (/ 1.0 x) (/ 2.0 (pow x 2.0)))) (* 2.0 (cbrt (/ 1.0 x))))))
(/
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)) <= 4e-11) {
tmp = (1.0 + (x - x)) / (x * (cbrt(((1.0 / x) + (2.0 / pow(x, 2.0)))) + (2.0 * cbrt((1.0 / x)))));
} 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)) <= 4e-11) tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(cbrt(Float64(Float64(1.0 / x) + Float64(2.0 / (x ^ 2.0)))) + Float64(2.0 * cbrt(Float64(1.0 / x)))))); 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], 4e-11], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Power[N[(N[(1.0 / x), $MachinePrecision] + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(2.0 * N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]), $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 4 \cdot 10^{-11}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt[3]{\frac{1}{x} + \frac{2}{{x}^{2}}} + 2 \cdot \sqrt[3]{\frac{1}{x}}\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 #s(literal 1 binary64))) (cbrt.f64 x)) < 3.99999999999999976e-11Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.6%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+93.3%
+-commutative93.3%
+-commutative93.3%
Simplified93.3%
Taylor expanded in x around inf 93.3%
*-commutative93.3%
Simplified93.3%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
if 3.99999999999999976e-11 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 61.4%
flip3--67.4%
div-inv67.4%
rem-cube-cbrt63.4%
rem-cube-cbrt98.4%
+-commutative98.4%
distribute-rgt-out98.2%
+-commutative98.2%
fma-define98.3%
add-exp-log98.2%
Applied egg-rr98.5%
associate-*r/98.5%
*-rgt-identity98.5%
+-commutative98.5%
associate--l+98.6%
+-commutative98.6%
+-commutative98.6%
Simplified98.6%
*-commutative98.6%
log1p-undefine98.6%
exp-to-pow98.6%
Applied egg-rr98.6%
Taylor expanded in x around 0 98.6%
Final simplification98.8%
(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 6.7%
flip3--7.0%
div-inv7.0%
rem-cube-cbrt6.1%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.7%
associate-*r/8.7%
*-rgt-identity8.7%
+-commutative8.7%
associate--l+93.5%
+-commutative93.5%
+-commutative93.5%
Simplified93.5%
*-commutative93.5%
log1p-undefine93.5%
exp-to-pow93.0%
metadata-eval93.0%
pow-prod-up93.0%
+-commutative93.0%
pow1/394.5%
expm1-log1p-u94.7%
+-commutative94.7%
pow1/395.6%
expm1-log1p-u94.4%
pow294.4%
expm1-log1p-u98.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 98.4%
(FPCore (x) :precision binary64 (/ (+ 1.0 (- x x)) (* x (+ (cbrt (+ (/ 1.0 x) (/ 2.0 (pow x 2.0)))) (* 2.0 (cbrt (/ 1.0 x)))))))
double code(double x) {
return (1.0 + (x - x)) / (x * (cbrt(((1.0 / x) + (2.0 / pow(x, 2.0)))) + (2.0 * cbrt((1.0 / x)))));
}
public static double code(double x) {
return (1.0 + (x - x)) / (x * (Math.cbrt(((1.0 / x) + (2.0 / Math.pow(x, 2.0)))) + (2.0 * Math.cbrt((1.0 / x)))));
}
function code(x) return Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(cbrt(Float64(Float64(1.0 / x) + Float64(2.0 / (x ^ 2.0)))) + Float64(2.0 * cbrt(Float64(1.0 / x)))))) end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Power[N[(N[(1.0 / x), $MachinePrecision] + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(2.0 * N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt[3]{\frac{1}{x} + \frac{2}{{x}^{2}}} + 2 \cdot \sqrt[3]{\frac{1}{x}}\right)}
\end{array}
Initial program 6.7%
flip3--7.0%
div-inv7.0%
rem-cube-cbrt6.1%
rem-cube-cbrt8.7%
+-commutative8.7%
distribute-rgt-out8.7%
+-commutative8.7%
fma-define8.7%
add-exp-log8.7%
Applied egg-rr8.7%
associate-*r/8.7%
*-rgt-identity8.7%
+-commutative8.7%
associate--l+93.5%
+-commutative93.5%
+-commutative93.5%
Simplified93.5%
Taylor expanded in x around inf 91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in x around inf 97.2%
associate-*r/97.2%
metadata-eval97.2%
Simplified97.2%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (/ (+ 1.0 (- x x)) (* 2.0 (pow (cbrt x) 2.0)))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = (1.0 + (x - x)) / (2.0 * pow(cbrt(x), 2.0));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
} else {
tmp = (1.0 + (x - x)) / (2.0 * Math.pow(Math.cbrt(x), 2.0));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(2.0 * (cbrt(x) ^ 2.0))); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{2 \cdot {\left(\sqrt[3]{x}\right)}^{2}}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 8.4%
Taylor expanded in x around inf 95.5%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.2%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+92.4%
+-commutative92.4%
+-commutative92.4%
Simplified92.4%
*-commutative92.4%
log1p-undefine92.4%
exp-to-pow91.6%
metadata-eval91.6%
pow-prod-up91.6%
+-commutative91.6%
pow1/393.1%
expm1-log1p-u93.4%
+-commutative93.4%
pow1/394.6%
expm1-log1p-u93.2%
pow293.2%
expm1-log1p-u98.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 4.8%
unpow24.8%
rem-cube-cbrt4.8%
rem-cube-cbrt4.8%
cube-prod4.8%
unpow24.8%
rem-cbrt-cube19.9%
Simplified19.9%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (/ 1.0 (+ 1.0 (* (cbrt x) (+ 1.0 (cbrt x)))))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (cbrt(x) * (1.0 + cbrt(x))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (1.0 + Math.cbrt(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(1.0 + cbrt(x))))); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(1 + \sqrt[3]{x}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 8.4%
Taylor expanded in x around inf 95.5%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.2%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+92.4%
+-commutative92.4%
+-commutative92.4%
Simplified92.4%
*-commutative92.4%
log1p-undefine92.4%
exp-to-pow91.6%
metadata-eval91.6%
pow-prod-up91.6%
+-commutative91.6%
pow1/393.1%
expm1-log1p-u93.4%
+-commutative93.4%
pow1/394.6%
expm1-log1p-u93.2%
pow293.2%
expm1-log1p-u98.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 17.7%
(FPCore (x) :precision binary64 (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
double code(double x) {
return 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
public static double code(double x) {
return 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
function code(x) return Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))) end
code[x_] := N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}
\end{array}
Initial program 6.7%
Taylor expanded in x around inf 52.7%
(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 6.7%
Final simplification6.7%
(FPCore (x) :precision binary64 (cbrt x))
double code(double x) {
return cbrt(x);
}
public static double code(double x) {
return Math.cbrt(x);
}
function code(x) return cbrt(x) end
code[x_] := N[Power[x, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x}
\end{array}
Initial program 6.7%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.3%
fabs-neg5.3%
unpow1/35.3%
metadata-eval5.3%
pow-sqr5.3%
fabs-sqr5.3%
pow-sqr5.3%
metadata-eval5.3%
unpow1/35.3%
Simplified5.3%
Taylor expanded in x around inf 5.3%
(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 6.7%
pow1/34.1%
pow-to-exp5.0%
+-commutative5.0%
log1p-define5.0%
Applied egg-rr5.0%
*-commutative5.0%
exp-prod5.3%
Applied egg-rr5.3%
Taylor expanded in x around inf 4.1%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ x 1.0)))) (/ 1.0 (+ (+ (* t_0 t_0) (* (cbrt x) t_0)) (* (cbrt x) (cbrt x))))))
double code(double x) {
double t_0 = cbrt((x + 1.0));
return 1.0 / (((t_0 * t_0) + (cbrt(x) * t_0)) + (cbrt(x) * cbrt(x)));
}
public static double code(double x) {
double t_0 = Math.cbrt((x + 1.0));
return 1.0 / (((t_0 * t_0) + (Math.cbrt(x) * t_0)) + (Math.cbrt(x) * Math.cbrt(x)));
}
function code(x) t_0 = cbrt(Float64(x + 1.0)) return Float64(1.0 / Float64(Float64(Float64(t_0 * t_0) + Float64(cbrt(x) * t_0)) + Float64(cbrt(x) * cbrt(x)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x + 1}\\
\frac{1}{\left(t\_0 \cdot t\_0 + \sqrt[3]{x} \cdot t\_0\right) + \sqrt[3]{x} \cdot \sqrt[3]{x}}
\end{array}
\end{array}
herbie shell --seed 2024181
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (cbrt (+ x 1)) (cbrt (+ x 1))) (* (cbrt x) (cbrt (+ x 1))) (* (cbrt x) (cbrt x)))))
(- (cbrt (+ x 1.0)) (cbrt x)))