
(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 12 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 (sqrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (* t_0 t_0)) (pow (cbrt (+ 1.0 x)) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + (t_0 * t_0)), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(t_0 * t_0)), (cbrt(Float64(1.0 + x)) ^ 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[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $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} + t\_0 \cdot t\_0, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 7.1%
flip3--7.5%
div-inv7.5%
rem-cube-cbrt6.8%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.1%
Applied egg-rr10.1%
associate-*r/10.1%
*-rgt-identity10.1%
+-commutative10.1%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.4%
Simplified92.4%
add-sqr-sqrt92.4%
unpow-prod-down94.1%
Applied egg-rr94.1%
pow-prod-down92.4%
add-sqr-sqrt92.4%
pow-exp93.2%
*-commutative93.2%
log1p-undefine93.2%
+-commutative93.2%
pow-to-exp93.1%
metadata-eval93.1%
pow-sqr93.1%
pow1/394.6%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
pow1/394.6%
+-commutative94.6%
add-sqr-sqrt94.6%
unpow-prod-down94.6%
+-commutative94.6%
add-sqr-sqrt94.6%
hypot-1-def94.6%
+-commutative94.6%
add-sqr-sqrt94.6%
hypot-1-def94.6%
Applied egg-rr94.6%
unpow1/396.0%
hypot-undefine96.0%
metadata-eval96.0%
rem-square-sqrt96.0%
unpow1/398.5%
hypot-undefine98.5%
metadata-eval98.5%
rem-square-sqrt98.5%
Simplified98.5%
Final simplification98.5%
(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 (pow (cbrt 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, pow(cbrt(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, 1/3], $MachinePrecision], 2.0], $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, {\left(\sqrt[3]{x}\right)}^{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.3%
rem-cube-cbrt4.6%
+-commutative4.6%
distribute-rgt-out4.6%
+-commutative4.6%
fma-define4.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
+-commutative4.6%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.1%
Simplified92.1%
Taylor expanded in x around inf 45.9%
unpow1/348.0%
Simplified48.0%
unpow248.0%
cbrt-prod98.4%
*-un-lft-identity98.4%
pow298.4%
Applied egg-rr98.4%
*-lft-identity98.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 52.9%
add-sqr-sqrt51.3%
pow251.3%
pow1/348.4%
sqrt-pow148.2%
metadata-eval48.2%
Applied egg-rr48.2%
Applied egg-rr98.7%
Final simplification98.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 7.1%
flip3--7.5%
div-inv7.5%
rem-cube-cbrt6.8%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.1%
Applied egg-rr10.1%
associate-*r/10.1%
*-rgt-identity10.1%
+-commutative10.1%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.4%
Simplified92.4%
add-sqr-sqrt92.4%
unpow-prod-down94.1%
Applied egg-rr94.1%
pow-prod-down92.4%
add-sqr-sqrt92.4%
pow-exp93.2%
*-commutative93.2%
log1p-undefine93.2%
+-commutative93.2%
pow-to-exp93.1%
metadata-eval93.1%
pow-sqr93.1%
pow1/394.6%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= x 5e+15)
(/ (- (+ 1.0 x) x) (+ (pow t_0 2.0) (* (cbrt x) t_1)))
(/ 1.0 (* (cbrt x) (+ (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 (x <= 5e+15) {
tmp = ((1.0 + x) - x) / (pow(t_0, 2.0) + (cbrt(x) * t_1));
} else {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + t_1));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = Math.cbrt(x) + t_0;
double tmp;
if (x <= 5e+15) {
tmp = ((1.0 + x) - x) / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * t_1));
} else {
tmp = 1.0 / (Math.cbrt(x) * (Math.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 (x <= 5e+15) tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * t_1))); else tmp = Float64(1.0 / Float64(cbrt(x) * 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[x, 5e+15], 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], N[(1.0 / N[(N[Power[x, 1/3], $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}\;x \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{{t\_0}^{2} + \sqrt[3]{x} \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_1\right)}\\
\end{array}
\end{array}
if x < 5e15Initial program 49.8%
add-sqr-sqrt48.3%
pow248.3%
pow1/346.4%
sqrt-pow146.2%
metadata-eval46.2%
Applied egg-rr46.2%
Applied egg-rr98.8%
if 5e15 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt2.9%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-define4.2%
add-exp-log4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.1%
Simplified92.1%
Taylor expanded in x around inf 45.7%
unpow1/347.8%
Simplified47.8%
fma-undefine47.8%
+-commutative47.8%
unpow247.8%
cbrt-prod98.3%
pow298.3%
+-commutative98.3%
+-commutative98.3%
Applied egg-rr98.3%
unpow298.3%
distribute-lft-out98.4%
+-commutative98.4%
+-commutative98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x 5e+14)
(/ 1.0 (fma (cbrt x) t_0 (pow (+ 1.0 x) 0.6666666666666666)))
(/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= 5e+14) {
tmp = 1.0 / fma(cbrt(x), t_0, pow((1.0 + x), 0.6666666666666666));
} else {
tmp = 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * t_0));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= 5e+14) tmp = Float64(1.0 / fma(cbrt(x), t_0, (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * t_0))); 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, 5e+14], 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], N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot t\_0}\\
\end{array}
\end{array}
if x < 5e14Initial program 58.0%
flip3--66.0%
div-inv66.0%
rem-cube-cbrt64.1%
rem-cube-cbrt98.6%
+-commutative98.6%
distribute-rgt-out98.6%
+-commutative98.6%
fma-define98.7%
add-exp-log98.3%
Applied egg-rr97.9%
associate-*r/97.9%
*-rgt-identity97.9%
+-commutative97.9%
associate--l+98.0%
+-inverses98.0%
metadata-eval98.0%
+-commutative98.0%
exp-prod97.7%
Simplified97.7%
add-sqr-sqrt97.7%
unpow-prod-down98.5%
Applied egg-rr98.5%
pow-prod-down97.7%
add-sqr-sqrt97.7%
pow-exp98.0%
*-commutative98.0%
log1p-undefine98.0%
+-commutative98.0%
pow-to-exp98.1%
Applied egg-rr98.1%
if 5e14 < x Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.8%
rem-cube-cbrt5.4%
+-commutative5.4%
distribute-rgt-out5.4%
+-commutative5.4%
fma-define5.4%
add-exp-log5.4%
Applied egg-rr5.4%
associate-*r/5.4%
*-rgt-identity5.4%
+-commutative5.4%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.1%
Simplified92.1%
Taylor expanded in x around inf 46.3%
unpow1/348.4%
Simplified48.4%
fma-undefine48.4%
+-commutative48.4%
unpow248.4%
cbrt-prod98.4%
pow298.4%
+-commutative98.4%
+-commutative98.4%
Applied egg-rr98.4%
Final simplification98.3%
(FPCore (x) :precision binary64 (/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))))))
double code(double x) {
return 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))));
}
public static double code(double x) {
return 1.0 / (Math.pow(Math.cbrt(x), 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
}
function code(x) return Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))) end
code[x_] := N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + 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]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)}
\end{array}
Initial program 7.1%
flip3--7.5%
div-inv7.5%
rem-cube-cbrt6.8%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.1%
Applied egg-rr10.1%
associate-*r/10.1%
*-rgt-identity10.1%
+-commutative10.1%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.4%
Simplified92.4%
Taylor expanded in x around inf 47.2%
unpow1/349.2%
Simplified49.2%
fma-undefine49.2%
+-commutative49.2%
unpow249.2%
cbrt-prod96.6%
pow296.6%
+-commutative96.6%
+-commutative96.6%
Applied egg-rr96.6%
Final simplification96.6%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) 1.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;
} 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;
} 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 = 1.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], 1.0, t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
Taylor expanded in x around 0 5.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 52.9%
Final simplification8.7%
(FPCore (x) :precision binary64 (if (<= x 1.1e+15) (- (pow (+ 1.0 x) 0.3333333333333333) (pow (pow x 0.16666666666666666) 2.0)) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.1e+15) {
tmp = pow((1.0 + x), 0.3333333333333333) - pow(pow(x, 0.16666666666666666), 2.0);
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.1e+15) tmp = Float64((Float64(1.0 + x) ^ 0.3333333333333333) - ((x ^ 0.16666666666666666) ^ 2.0)); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.1e+15], N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] - N[Power[N[Power[x, 0.16666666666666666], $MachinePrecision], 2.0], $MachinePrecision]), $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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{+15}:\\
\;\;\;\;{\left(1 + x\right)}^{0.3333333333333333} - {\left({x}^{0.16666666666666666}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.1e15Initial program 55.2%
add-sqr-sqrt53.6%
pow253.6%
pow1/350.6%
sqrt-pow150.4%
metadata-eval50.4%
Applied egg-rr50.4%
pow1/356.2%
Applied egg-rr56.2%
if 1.1e15 < x Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.7%
rem-cube-cbrt5.0%
+-commutative5.0%
distribute-rgt-out5.0%
+-commutative5.0%
fma-define5.0%
add-exp-log5.0%
Applied egg-rr5.0%
associate-*r/5.0%
*-rgt-identity5.0%
+-commutative5.0%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.1%
Simplified92.1%
Taylor expanded in x around 0 20.0%
Final simplification21.9%
(FPCore (x) :precision binary64 (/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))))))
double code(double x) {
return 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + cbrt((1.0 + x)))));
}
public static double code(double x) {
return 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
}
function code(x) return Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * 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]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)\right)}
\end{array}
Initial program 7.1%
flip3--7.5%
div-inv7.5%
rem-cube-cbrt6.8%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.1%
Applied egg-rr10.1%
associate-*r/10.1%
*-rgt-identity10.1%
+-commutative10.1%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.4%
Simplified92.4%
Taylor expanded in x around inf 47.2%
unpow1/349.2%
Simplified49.2%
fma-undefine49.2%
+-commutative49.2%
unpow249.2%
cbrt-prod96.6%
pow296.6%
+-commutative96.6%
+-commutative96.6%
Applied egg-rr96.6%
unpow296.6%
distribute-lft-out96.6%
+-commutative96.6%
+-commutative96.6%
Simplified96.6%
Final simplification96.6%
(FPCore (x) :precision binary64 (- (cbrt (+ 1.0 x)) (pow x 0.3333333333333333)))
double code(double x) {
return cbrt((1.0 + x)) - pow(x, 0.3333333333333333);
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) - Math.pow(x, 0.3333333333333333);
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) - (x ^ 0.3333333333333333)) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} - {x}^{0.3333333333333333}
\end{array}
Initial program 7.1%
pow1/37.9%
Applied egg-rr7.9%
Final simplification7.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 7.1%
Taylor expanded in x around inf 4.2%
Final simplification4.2%
(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 7.1%
Taylor expanded in x around 0 6.3%
Final simplification6.3%
(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 2024047
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(/ 1.0 (+ (+ (* (cbrt (+ x 1.0)) (cbrt (+ x 1.0))) (* (cbrt x) (cbrt (+ x 1.0)))) (* (cbrt x) (cbrt x))))
(- (cbrt (+ x 1.0)) (cbrt x)))