
(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 (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 6.6%
flip3--6.6%
div-inv6.6%
rem-cube-cbrt6.1%
rem-cube-cbrt8.0%
+-commutative8.0%
distribute-rgt-out8.0%
+-commutative8.0%
fma-define8.0%
add-exp-log8.0%
Applied egg-rr7.9%
associate-*r/7.9%
*-rgt-identity7.9%
+-commutative7.9%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.2%
Simplified92.2%
pow-exp93.2%
*-commutative93.2%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow92.9%
metadata-eval92.9%
pow-prod-up92.9%
+-commutative92.9%
pow1/394.4%
+-commutative94.4%
pow1/398.5%
Applied egg-rr98.5%
pow1/394.4%
+-commutative94.4%
add-sqr-sqrt94.4%
unpow-prod-down94.4%
+-commutative94.4%
+-commutative94.4%
Applied egg-rr94.4%
unpow1/395.8%
unpow1/398.6%
Simplified98.6%
pow298.6%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (x)
:precision binary64
(if (<= x 6e+14)
(/
1.0
(+
(+ (pow (cbrt x) 2.0) (cbrt (* x (+ 1.0 x))))
(pow (+ 1.0 x) 0.6666666666666666)))
(if (<= x 1.35e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/
1.0
(fma
(cbrt x)
(* (cbrt x) 2.0)
(exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double tmp;
if (x <= 6e+14) {
tmp = 1.0 / ((pow(cbrt(x), 2.0) + cbrt((x * (1.0 + x)))) + pow((1.0 + x), 0.6666666666666666));
} else if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 6e+14) tmp = Float64(1.0 / Float64(Float64((cbrt(x) ^ 2.0) + cbrt(Float64(x * Float64(1.0 + x)))) + (Float64(1.0 + x) ^ 0.6666666666666666))); elseif (x <= 1.35e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := If[LessEqual[x, 6e+14], N[(1.0 / N[(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] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\left({\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x \cdot \left(1 + x\right)}\right) + {\left(1 + x\right)}^{0.6666666666666666}}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if x < 6e14Initial program 64.6%
flip3--64.4%
div-inv64.4%
rem-cube-cbrt75.1%
rem-cube-cbrt98.8%
+-commutative98.8%
distribute-rgt-out99.0%
+-commutative99.0%
fma-define99.0%
add-exp-log99.0%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
+-commutative98.1%
associate--l+98.1%
+-inverses98.1%
metadata-eval98.1%
+-commutative98.1%
exp-prod97.7%
Simplified97.7%
fma-undefine98.1%
+-commutative98.1%
+-commutative98.1%
+-commutative98.1%
distribute-rgt-in98.1%
associate-+r+98.1%
pow298.1%
cbrt-unprod97.7%
+-commutative97.7%
Applied egg-rr97.7%
associate-+l+98.0%
exp-prod98.2%
*-commutative98.2%
Simplified98.2%
*-commutative98.2%
exp-prod98.2%
log1p-undefine98.2%
add-exp-log98.1%
Applied egg-rr98.1%
if 6e14 < x < 1.35000000000000003e154Initial program 3.7%
Taylor expanded in x around inf 98.7%
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+91.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.8%
Simplified90.8%
pow-exp91.8%
Applied egg-rr91.8%
Taylor expanded in x around inf 91.8%
*-commutative98.6%
Simplified91.8%
Final simplification95.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 2.25e+17)
(/
1.0
(+
(exp (* 0.6666666666666666 (log1p x)))
(+ (pow (cbrt x) 2.0) (cbrt (* x (+ 1.0 x))))))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (* t_0 t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 2.25e+17) {
tmp = 1.0 / (exp((0.6666666666666666 * log1p(x))) + (pow(cbrt(x), 2.0) + cbrt((x * (1.0 + x)))));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), (t_0 * t_0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 2.25e+17) tmp = Float64(1.0 / Float64(exp(Float64(0.6666666666666666 * log1p(x))) + Float64((cbrt(x) ^ 2.0) + cbrt(Float64(x * Float64(1.0 + x)))))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), Float64(t_0 * t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 2.25e+17], N[(1.0 / N[(N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $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], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 2.25 \cdot 10^{+17}:\\
\;\;\;\;\frac{1}{e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)} + \left({\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x \cdot \left(1 + x\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, t\_0 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 2.25e17Initial program 55.4%
flip3--55.3%
div-inv55.3%
rem-cube-cbrt64.1%
rem-cube-cbrt84.2%
+-commutative84.2%
distribute-rgt-out84.3%
+-commutative84.3%
fma-define84.3%
add-exp-log84.4%
Applied egg-rr83.6%
associate-*r/83.6%
*-rgt-identity83.6%
+-commutative83.6%
associate--l+98.1%
+-inverses98.1%
metadata-eval98.1%
+-commutative98.1%
exp-prod97.5%
Simplified97.5%
fma-undefine97.8%
+-commutative97.8%
+-commutative97.8%
+-commutative97.8%
distribute-rgt-in97.8%
associate-+r+97.8%
pow297.8%
cbrt-unprod97.5%
+-commutative97.5%
Applied egg-rr97.5%
associate-+l+97.7%
exp-prod98.3%
*-commutative98.3%
Simplified98.3%
if 2.25e17 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.3%
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-prod91.9%
Simplified91.9%
pow-exp92.9%
*-commutative92.9%
log1p-undefine92.9%
+-commutative92.9%
exp-to-pow92.7%
metadata-eval92.7%
pow-prod-up92.7%
+-commutative92.7%
pow1/394.2%
+-commutative94.2%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
*-commutative98.4%
Simplified98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 2e+14)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow (+ 1.0 x) 0.6666666666666666)))
(/ 1.0 (fma (cbrt x) (* (cbrt x) 2.0) (* t_0 t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 2e+14) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow((1.0 + x), 0.6666666666666666));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) * 2.0), (t_0 * t_0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 2e+14) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) * 2.0), Float64(t_0 * t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 2e+14], 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], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, t\_0 \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 2e14Initial program 64.6%
flip3--64.4%
div-inv64.4%
rem-cube-cbrt75.1%
rem-cube-cbrt98.8%
+-commutative98.8%
distribute-rgt-out99.0%
+-commutative99.0%
fma-define99.0%
add-exp-log99.0%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
+-commutative98.1%
associate--l+98.1%
+-inverses98.1%
metadata-eval98.1%
+-commutative98.1%
exp-prod97.7%
Simplified97.7%
pow-exp98.1%
*-commutative98.1%
log1p-undefine98.1%
+-commutative98.1%
exp-to-pow98.2%
metadata-eval98.2%
pow-prod-up98.1%
+-commutative98.1%
pow1/399.1%
+-commutative99.1%
pow1/399.0%
Applied egg-rr99.0%
pow299.0%
pow1/398.1%
+-commutative98.1%
pow-pow98.2%
+-commutative98.2%
metadata-eval98.2%
Applied egg-rr98.2%
if 2e14 < x Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.3%
rem-cube-cbrt4.3%
+-commutative4.3%
distribute-rgt-out4.3%
+-commutative4.3%
fma-define4.3%
add-exp-log4.3%
Applied egg-rr4.3%
associate-*r/4.3%
*-rgt-identity4.3%
+-commutative4.3%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.0%
Simplified92.0%
pow-exp93.0%
*-commutative93.0%
log1p-undefine93.0%
+-commutative93.0%
exp-to-pow92.7%
metadata-eval92.7%
pow-prod-up92.7%
+-commutative92.7%
pow1/394.2%
+-commutative94.2%
pow1/398.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (pow t_0 2.0) (* (cbrt x) (+ (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / (pow(t_0, 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{{t\_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}
\end{array}
\end{array}
Initial program 6.6%
flip3--6.6%
div-inv6.6%
rem-cube-cbrt6.1%
rem-cube-cbrt8.0%
+-commutative8.0%
distribute-rgt-out8.0%
+-commutative8.0%
fma-define8.0%
add-exp-log8.0%
Applied egg-rr7.9%
associate-*r/7.9%
*-rgt-identity7.9%
+-commutative7.9%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.2%
Simplified92.2%
pow-exp93.2%
*-commutative93.2%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow92.9%
metadata-eval92.9%
pow-prod-up92.9%
+-commutative92.9%
pow1/394.4%
+-commutative94.4%
pow1/398.5%
Applied egg-rr98.5%
fma-undefine98.5%
+-commutative98.5%
pow298.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (pow (+ 1.0 x) 0.6666666666666666))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((1.0 + x), 0.6666666666666666));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(1.0 + x) ^ 0.6666666666666666))) 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] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(1 + x\right)}^{0.6666666666666666}\right)}
\end{array}
Initial program 6.6%
flip3--6.6%
div-inv6.6%
rem-cube-cbrt6.1%
rem-cube-cbrt8.0%
+-commutative8.0%
distribute-rgt-out8.0%
+-commutative8.0%
fma-define8.0%
add-exp-log8.0%
Applied egg-rr7.9%
associate-*r/7.9%
*-rgt-identity7.9%
+-commutative7.9%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.2%
Simplified92.2%
pow-exp93.2%
*-commutative93.2%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow92.9%
metadata-eval92.9%
pow-prod-up92.9%
+-commutative92.9%
pow1/394.4%
+-commutative94.4%
pow1/398.5%
Applied egg-rr98.5%
pow298.5%
pow1/392.9%
+-commutative92.9%
pow-pow92.9%
+-commutative92.9%
metadata-eval92.9%
Applied egg-rr92.9%
Final simplification92.9%
(FPCore (x)
:precision binary64
(if (<= x 6e+14)
(/
1.0
(+
(+ (pow (cbrt x) 2.0) (cbrt (* x (+ 1.0 x))))
(pow (+ 1.0 x) 0.6666666666666666)))
(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 <= 6e+14) {
tmp = 1.0 / ((pow(cbrt(x), 2.0) + cbrt((x * (1.0 + x)))) + pow((1.0 + x), 0.6666666666666666));
} else 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 <= 6e+14) {
tmp = 1.0 / ((Math.pow(Math.cbrt(x), 2.0) + Math.cbrt((x * (1.0 + x)))) + Math.pow((1.0 + x), 0.6666666666666666));
} else 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 <= 6e+14) tmp = Float64(1.0 / Float64(Float64((cbrt(x) ^ 2.0) + cbrt(Float64(x * Float64(1.0 + x)))) + (Float64(1.0 + x) ^ 0.6666666666666666))); elseif (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, 6e+14], N[(1.0 / N[(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] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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 6 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\left({\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x \cdot \left(1 + x\right)}\right) + {\left(1 + x\right)}^{0.6666666666666666}}\\
\mathbf{elif}\;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 < 6e14Initial program 64.6%
flip3--64.4%
div-inv64.4%
rem-cube-cbrt75.1%
rem-cube-cbrt98.8%
+-commutative98.8%
distribute-rgt-out99.0%
+-commutative99.0%
fma-define99.0%
add-exp-log99.0%
Applied egg-rr98.1%
associate-*r/98.1%
*-rgt-identity98.1%
+-commutative98.1%
associate--l+98.1%
+-inverses98.1%
metadata-eval98.1%
+-commutative98.1%
exp-prod97.7%
Simplified97.7%
fma-undefine98.1%
+-commutative98.1%
+-commutative98.1%
+-commutative98.1%
distribute-rgt-in98.1%
associate-+r+98.1%
pow298.1%
cbrt-unprod97.7%
+-commutative97.7%
Applied egg-rr97.7%
associate-+l+98.0%
exp-prod98.2%
*-commutative98.2%
Simplified98.2%
*-commutative98.2%
exp-prod98.2%
log1p-undefine98.2%
add-exp-log98.1%
Applied egg-rr98.1%
if 6e14 < x < 1.35000000000000003e154Initial program 3.7%
Taylor expanded in x around inf 98.7%
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+91.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.8%
Simplified90.8%
Taylor expanded in x around 0 17.7%
Final simplification58.5%
(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.5%
Taylor expanded in x around inf 95.2%
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+91.8%
+-inverses91.8%
metadata-eval91.8%
+-commutative91.8%
exp-prod90.8%
Simplified90.8%
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.6%
Taylor expanded in x around inf 50.3%
(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.6%
Final simplification6.6%
(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.6%
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 (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 2024141
(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)))