
(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 14 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
(fma
(cbrt x)
(/ (+ x (+ 1.0 x)) (+ t_1 (* (cbrt x) (- (cbrt x) 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 / fma(cbrt(x), ((x + (1.0 + x)) / (t_1 + (cbrt(x) * (cbrt(x) - t_0)))), t_1);
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = t_0 ^ 2.0 return Float64(1.0 / fma(cbrt(x), Float64(Float64(x + Float64(1.0 + x)) / Float64(t_1 + Float64(cbrt(x) * Float64(cbrt(x) - 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[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[(x + N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] - t$95$0), $MachinePrecision]), $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}{\mathsf{fma}\left(\sqrt[3]{x}, \frac{x + \left(1 + x\right)}{t\_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - t\_0\right)}, t\_1\right)}
\end{array}
\end{array}
Initial program 7.7%
flip3--8.3%
div-inv8.3%
rem-cube-cbrt7.0%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.0%
Applied egg-rr10.0%
associate-*r/10.0%
*-rgt-identity10.0%
+-commutative10.0%
associate--l+93.7%
+-inverses93.7%
metadata-eval93.7%
+-commutative93.7%
exp-prod92.5%
Simplified92.5%
add-sqr-sqrt92.5%
unpow-prod-down94.3%
Applied egg-rr94.3%
add-sqr-sqrt94.3%
pow294.3%
sqrt-prod94.3%
add-sqr-sqrt94.3%
add-exp-log93.8%
log-pow93.7%
log1p-undefine93.7%
+-commutative93.7%
pow1/293.7%
log-pow93.7%
rem-log-exp93.7%
metadata-eval93.7%
pow-to-exp93.2%
pow1/398.4%
Applied egg-rr98.4%
flip3-+98.5%
pow1/392.3%
+-commutative92.3%
add-sqr-sqrt92.3%
unpow292.3%
pow1/398.5%
rem-cube-cbrt99.0%
rem-cube-cbrt99.4%
+-commutative99.4%
unpow299.4%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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) 2.0) (pow t_0 2.0)))
(/
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)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(t_0, 2.0));
} 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)) <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (t_0 ^ 2.0))); 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], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[t$95$0, 2.0], $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 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {t\_0}^{2}\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)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.4%
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+93.4%
+-inverses93.4%
metadata-eval93.4%
+-commutative93.4%
exp-prod92.2%
Simplified92.2%
add-sqr-sqrt92.2%
unpow-prod-down94.1%
Applied egg-rr94.1%
add-sqr-sqrt94.1%
pow294.1%
sqrt-prod94.1%
add-sqr-sqrt94.1%
add-exp-log93.6%
log-pow93.4%
log1p-undefine93.4%
+-commutative93.4%
pow1/293.4%
log-pow93.4%
rem-log-exp93.4%
metadata-eval93.4%
pow-to-exp92.9%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x #s(literal 1 binary64))) (cbrt.f64 x)) Initial program 64.8%
flip3--74.4%
div-inv74.4%
rem-cube-cbrt64.3%
rem-cube-cbrt98.5%
+-commutative98.5%
distribute-rgt-out98.6%
+-commutative98.6%
fma-define98.5%
add-exp-log98.1%
Applied egg-rr97.9%
associate-*r/97.9%
*-rgt-identity97.9%
+-commutative97.9%
associate--l+97.9%
+-inverses97.9%
metadata-eval97.9%
+-commutative97.9%
exp-prod97.5%
Simplified97.5%
add-sqr-sqrt97.5%
unpow-prod-down98.1%
Applied egg-rr98.1%
add-sqr-sqrt98.1%
pow298.1%
sqrt-prod98.3%
add-sqr-sqrt98.1%
add-exp-log98.0%
log-pow97.9%
log1p-undefine97.9%
+-commutative97.9%
pow1/297.9%
log-pow97.9%
rem-log-exp97.9%
metadata-eval97.9%
pow-to-exp98.1%
pow1/398.5%
pow298.5%
pow1/398.5%
pow1/398.1%
pow-prod-up98.2%
Applied egg-rr98.2%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 4e+153)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (cbrt (pow (+ 1.0 x) 2.0))))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (pow t_0 2.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 4e+153) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(t_0, 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 4e+153) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), cbrt((Float64(1.0 + x) ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (t_0 ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 4e+153], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 4 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {t\_0}^{2}\right)}\\
\end{array}
\end{array}
if x < 4e153Initial program 10.8%
flip3--12.0%
div-inv12.0%
rem-cube-cbrt11.0%
rem-cube-cbrt15.6%
+-commutative15.6%
distribute-rgt-out15.6%
+-commutative15.6%
fma-define15.6%
add-exp-log15.6%
Applied egg-rr15.5%
associate-*r/15.5%
*-rgt-identity15.5%
+-commutative15.5%
associate--l+95.0%
+-inverses95.0%
metadata-eval95.0%
+-commutative95.0%
exp-prod94.2%
Simplified94.2%
add-cube-cbrt92.4%
pow392.3%
Applied egg-rr92.3%
unpow392.4%
add-sqr-sqrt92.4%
add-cube-cbrt94.2%
pow-prod-down95.8%
add-sqr-sqrt95.8%
pow295.8%
Applied egg-rr98.8%
if 4e153 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
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+92.4%
+-inverses92.4%
metadata-eval92.4%
+-commutative92.4%
exp-prod90.9%
Simplified90.9%
add-sqr-sqrt90.9%
unpow-prod-down92.9%
Applied egg-rr92.9%
add-sqr-sqrt92.9%
pow292.9%
sqrt-prod92.9%
add-sqr-sqrt92.9%
add-exp-log92.5%
log-pow92.4%
log1p-undefine92.4%
+-commutative92.4%
pow1/292.4%
log-pow92.4%
rem-log-exp92.4%
metadata-eval92.4%
pow-to-exp91.6%
pow1/398.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.3%
Final simplification98.6%
(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.7%
flip3--8.3%
div-inv8.3%
rem-cube-cbrt7.0%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.0%
Applied egg-rr10.0%
associate-*r/10.0%
*-rgt-identity10.0%
+-commutative10.0%
associate--l+93.7%
+-inverses93.7%
metadata-eval93.7%
+-commutative93.7%
exp-prod92.5%
Simplified92.5%
add-sqr-sqrt92.5%
unpow-prod-down94.3%
Applied egg-rr94.3%
add-sqr-sqrt94.3%
pow294.3%
sqrt-prod94.3%
add-sqr-sqrt94.3%
add-exp-log93.8%
log-pow93.7%
log1p-undefine93.7%
+-commutative93.7%
pow1/293.7%
log-pow93.7%
rem-log-exp93.7%
metadata-eval93.7%
pow-to-exp93.2%
pow1/398.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (pow t_0 2.0)))
(if (<= x 1e+14)
(/ (- (+ 1.0 x) x) (+ t_1 (* (cbrt x) (+ (cbrt x) t_0))))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) t_1)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = pow(t_0, 2.0);
double tmp;
if (x <= 1e+14) {
tmp = ((1.0 + x) - x) / (t_1 + (cbrt(x) * (cbrt(x) + t_0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), t_1);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = t_0 ^ 2.0 tmp = 0.0 if (x <= 1e+14) tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(t_1 + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 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[Power[t$95$0, 2.0], $MachinePrecision]}, If[LessEqual[x, 1e+14], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := {t\_0}^{2}\\
\mathbf{if}\;x \leq 10^{+14}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{t\_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, t\_1\right)}\\
\end{array}
\end{array}
if x < 1e14Initial program 64.8%
add-exp-log60.2%
+-commutative60.2%
log1p-define60.2%
Applied egg-rr60.2%
Applied egg-rr98.6%
if 1e14 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.4%
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+93.4%
+-inverses93.4%
metadata-eval93.4%
+-commutative93.4%
exp-prod92.2%
Simplified92.2%
add-sqr-sqrt92.2%
unpow-prod-down94.1%
Applied egg-rr94.1%
add-sqr-sqrt94.1%
pow294.1%
sqrt-prod94.1%
add-sqr-sqrt94.1%
add-exp-log93.6%
log-pow93.4%
log1p-undefine93.4%
+-commutative93.4%
pow1/293.4%
log-pow93.4%
rem-log-exp93.4%
metadata-eval93.4%
pow-to-exp92.9%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
Final simplification98.4%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (pow (cbrt (+ 1.0 x)) 2.0))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $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}, \sqrt[3]{x} \cdot 2, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
Initial program 7.7%
flip3--8.3%
div-inv8.3%
rem-cube-cbrt7.0%
rem-cube-cbrt10.1%
+-commutative10.1%
distribute-rgt-out10.1%
+-commutative10.1%
fma-define10.1%
add-exp-log10.0%
Applied egg-rr10.0%
associate-*r/10.0%
*-rgt-identity10.0%
+-commutative10.0%
associate--l+93.7%
+-inverses93.7%
metadata-eval93.7%
+-commutative93.7%
exp-prod92.5%
Simplified92.5%
add-sqr-sqrt92.5%
unpow-prod-down94.3%
Applied egg-rr94.3%
add-sqr-sqrt94.3%
pow294.3%
sqrt-prod94.3%
add-sqr-sqrt94.3%
add-exp-log93.8%
log-pow93.7%
log1p-undefine93.7%
+-commutative93.7%
pow1/293.7%
log-pow93.7%
rem-log-exp93.7%
metadata-eval93.7%
pow-to-exp93.2%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 96.2%
Final simplification96.2%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.6666666666666666 (* (cbrt (/ 1.0 (pow x 2.0))) (pow (cbrt 0.5) 3.0))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.6666666666666666 * (cbrt((1.0 / pow(x, 2.0))) * pow(cbrt(0.5), 3.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.35e+154) tmp = Float64(0.6666666666666666 * Float64(cbrt(Float64(1.0 / (x ^ 2.0))) * (cbrt(0.5) ^ 3.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.35e+154], N[(0.6666666666666666 * N[(N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[Power[0.5, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $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.35 \cdot 10^{+154}:\\
\;\;\;\;0.6666666666666666 \cdot \left(\sqrt[3]{\frac{1}{{x}^{2}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3}\right)\\
\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.35000000000000003e154Initial program 10.8%
add-log-exp10.8%
add-sqr-sqrt10.7%
log-prod10.8%
Applied egg-rr10.8%
count-210.8%
+-commutative10.8%
Simplified10.8%
add-cube-cbrt10.8%
pow310.8%
pow1/210.8%
log-pow10.8%
add-log-exp10.8%
+-commutative10.8%
Applied egg-rr10.8%
Taylor expanded in x around inf 94.0%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
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+92.4%
+-inverses92.4%
metadata-eval92.4%
+-commutative92.4%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 20.0%
Final simplification56.7%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.6666666666666666 (* (cbrt (/ 1.0 (pow x 2.0))) (pow (cbrt 0.5) 3.0))) (/ 1.0 (+ 1.0 (* (cbrt x) (+ 1.0 (cbrt x)))))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.6666666666666666 * (cbrt((1.0 / pow(x, 2.0))) * pow(cbrt(0.5), 3.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.6666666666666666 * (Math.cbrt((1.0 / Math.pow(x, 2.0))) * Math.pow(Math.cbrt(0.5), 3.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.6666666666666666 * Float64(cbrt(Float64(1.0 / (x ^ 2.0))) * (cbrt(0.5) ^ 3.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.6666666666666666 * N[(N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[Power[0.5, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $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.6666666666666666 \cdot \left(\sqrt[3]{\frac{1}{{x}^{2}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(1 + \sqrt[3]{x}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 10.8%
add-log-exp10.8%
add-sqr-sqrt10.7%
log-prod10.8%
Applied egg-rr10.8%
count-210.8%
+-commutative10.8%
Simplified10.8%
add-cube-cbrt10.8%
pow310.8%
pow1/210.8%
log-pow10.8%
add-log-exp10.8%
+-commutative10.8%
Applied egg-rr10.8%
Taylor expanded in x around inf 94.0%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
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+92.4%
+-inverses92.4%
metadata-eval92.4%
+-commutative92.4%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 17.7%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* (cbrt (/ 1.0 (pow x 2.0))) 0.3333333333333333) (/ 1.0 (+ 1.0 (* (cbrt x) (+ 1.0 (cbrt x)))))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = cbrt((1.0 / pow(x, 2.0))) * 0.3333333333333333;
} 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 = Math.cbrt((1.0 / Math.pow(x, 2.0))) * 0.3333333333333333;
} 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(cbrt(Float64(1.0 / (x ^ 2.0))) * 0.3333333333333333); 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[(N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * 0.3333333333333333), $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}:\\
\;\;\;\;\sqrt[3]{\frac{1}{{x}^{2}}} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(1 + \sqrt[3]{x}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 10.8%
Taylor expanded in x around inf 93.8%
if 1.35000000000000003e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.1%
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+92.4%
+-inverses92.4%
metadata-eval92.4%
+-commutative92.4%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 17.7%
Final simplification55.5%
(FPCore (x) :precision binary64 (* (cbrt (/ 1.0 (pow x 2.0))) 0.3333333333333333))
double code(double x) {
return cbrt((1.0 / pow(x, 2.0))) * 0.3333333333333333;
}
public static double code(double x) {
return Math.cbrt((1.0 / Math.pow(x, 2.0))) * 0.3333333333333333;
}
function code(x) return Float64(cbrt(Float64(1.0 / (x ^ 2.0))) * 0.3333333333333333) end
code[x_] := N[(N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{{x}^{2}}} \cdot 0.3333333333333333
\end{array}
Initial program 7.7%
Taylor expanded in x around inf 48.9%
Final simplification48.9%
(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 7.7%
Final simplification7.7%
(FPCore (x) :precision binary64 (- (cbrt x) (pow x 0.3333333333333333)))
double code(double x) {
return cbrt(x) - pow(x, 0.3333333333333333);
}
public static double code(double x) {
return Math.cbrt(x) - Math.pow(x, 0.3333333333333333);
}
function code(x) return Float64(cbrt(x) - (x ^ 0.3333333333333333)) end
code[x_] := N[(N[Power[x, 1/3], $MachinePrecision] - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x} - {x}^{0.3333333333333333}
\end{array}
Initial program 7.7%
Taylor expanded in x around inf 4.1%
pow1/36.0%
Applied egg-rr6.0%
(FPCore (x) :precision binary64 (+ 1.0 (cbrt x)))
double code(double x) {
return 1.0 + cbrt(x);
}
public static double code(double x) {
return 1.0 + Math.cbrt(x);
}
function code(x) return Float64(1.0 + cbrt(x)) end
code[x_] := N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \sqrt[3]{x}
\end{array}
Initial program 7.7%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.5%
fabs-neg5.5%
unpow1/35.5%
metadata-eval5.5%
pow-sqr5.5%
fabs-sqr5.5%
pow-sqr5.5%
metadata-eval5.5%
unpow1/35.5%
Simplified5.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 7.7%
Taylor expanded in x around inf 4.1%
Taylor expanded in x around 0 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 2024117
(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)))