
(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 (/ (+ 1.0 (- x x)) (+ (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))) (* x (cbrt (fma 2.0 (pow x -2.0) (/ 1.0 x)))))))
double code(double x) {
return (1.0 + (x - x)) / ((cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))) + (x * cbrt(fma(2.0, pow(x, -2.0), (1.0 / x)))));
}
function code(x) return Float64(Float64(1.0 + Float64(x - x)) / Float64(Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))) + Float64(x * cbrt(fma(2.0, (x ^ -2.0), Float64(1.0 / x)))))) end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(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] + N[(x * N[Power[N[(2.0 * N[Power[x, -2.0], $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \left(x - x\right)}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right) + x \cdot \sqrt[3]{\mathsf{fma}\left(2, {x}^{-2}, \frac{1}{x}\right)}}
\end{array}
Initial program 5.9%
flip3--6.1%
div-inv6.1%
rem-cube-cbrt5.6%
rem-cube-cbrt7.2%
+-commutative7.2%
distribute-rgt-out7.1%
+-commutative7.1%
fma-define7.2%
add-exp-log7.1%
Applied egg-rr7.2%
associate-*r/7.2%
*-rgt-identity7.2%
+-commutative7.2%
associate--l+93.1%
+-commutative93.1%
+-commutative93.1%
Simplified93.1%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
fma-undefine98.5%
+-commutative98.5%
div-inv98.5%
fma-define98.5%
pow-flip98.5%
metadata-eval98.5%
Applied egg-rr98.5%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ (+ 1.0 (- x x)) (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 + (x - x)) / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(Float64(1.0 + Float64(x - x)) / 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[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {t\_0}^{2}\right)}
\end{array}
\end{array}
Initial program 5.9%
flip3--6.1%
div-inv6.1%
rem-cube-cbrt5.6%
rem-cube-cbrt7.2%
+-commutative7.2%
distribute-rgt-out7.1%
+-commutative7.1%
fma-define7.2%
add-exp-log7.1%
Applied egg-rr7.2%
associate-*r/7.2%
*-rgt-identity7.2%
+-commutative7.2%
associate--l+93.1%
+-commutative93.1%
+-commutative93.1%
Simplified93.1%
*-commutative93.1%
log1p-undefine93.1%
exp-to-pow92.9%
metadata-eval92.9%
pow-sqr92.9%
+-commutative92.9%
pow1/394.4%
+-commutative94.4%
pow1/398.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
(FPCore (x) :precision binary64 (/ (+ 1.0 (- x x)) (fma (cbrt x) (* (cbrt x) 2.0) (* x (cbrt (+ (/ 1.0 x) (/ 2.0 (pow x 2.0))))))))
double code(double x) {
return (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) * 2.0), (x * cbrt(((1.0 / x) + (2.0 / pow(x, 2.0))))));
}
function code(x) return Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) * 2.0), Float64(x * cbrt(Float64(Float64(1.0 / x) + Float64(2.0 / (x ^ 2.0))))))) end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[(x * N[Power[N[(N[(1.0 / x), $MachinePrecision] + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, x \cdot \sqrt[3]{\frac{1}{x} + \frac{2}{{x}^{2}}}\right)}
\end{array}
Initial program 5.9%
flip3--6.1%
div-inv6.1%
rem-cube-cbrt5.6%
rem-cube-cbrt7.2%
+-commutative7.2%
distribute-rgt-out7.1%
+-commutative7.1%
fma-define7.2%
add-exp-log7.1%
Applied egg-rr7.2%
associate-*r/7.2%
*-rgt-identity7.2%
+-commutative7.2%
associate--l+93.1%
+-commutative93.1%
+-commutative93.1%
Simplified93.1%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around inf 97.8%
*-commutative97.8%
Simplified97.8%
(FPCore (x)
:precision binary64
(if (<= x 1.34e+154)
(+
(* -0.1111111111111111 (cbrt (/ 1.0 (pow x 5.0))))
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
(/
(+ 1.0 (- x x))
(fma (cbrt x) (* (cbrt x) 2.0) (exp (* 0.6666666666666666 (log1p x)))))))
double code(double x) {
double tmp;
if (x <= 1.34e+154) {
tmp = (-0.1111111111111111 * cbrt((1.0 / pow(x, 5.0)))) + (0.3333333333333333 * cbrt((1.0 / pow(x, 2.0))));
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) * 2.0), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.34e+154) tmp = Float64(Float64(-0.1111111111111111 * cbrt(Float64(1.0 / (x ^ 5.0)))) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0))))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) * 2.0), exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := If[LessEqual[x, 1.34e+154], N[(N[(-0.1111111111111111 * N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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 1.34 \cdot 10^{+154}:\\
\;\;\;\;-0.1111111111111111 \cdot \sqrt[3]{\frac{1}{{x}^{5}}} + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\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 < 1.34000000000000001e154Initial program 6.9%
expm1-log1p-u7.8%
Applied egg-rr7.8%
Taylor expanded in x around inf 48.6%
+-commutative48.6%
fma-define48.6%
*-commutative48.6%
Simplified48.6%
Taylor expanded in x around inf 97.9%
if 1.34000000000000001e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.1%
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+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
Taylor expanded in x around inf 91.7%
*-commutative98.8%
Simplified91.7%
(FPCore (x) :precision binary64 (/ (+ 1.0 (- x x)) (fma (cbrt x) (* (cbrt x) 2.0) (pow (cbrt (+ 1.0 x)) 2.0))))
double code(double x) {
return (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) * 2.0), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) return Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) * 2.0), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
Initial program 5.9%
flip3--6.1%
div-inv6.1%
rem-cube-cbrt5.6%
rem-cube-cbrt7.2%
+-commutative7.2%
distribute-rgt-out7.1%
+-commutative7.1%
fma-define7.2%
add-exp-log7.1%
Applied egg-rr7.2%
associate-*r/7.2%
*-rgt-identity7.2%
+-commutative7.2%
associate--l+93.1%
+-commutative93.1%
+-commutative93.1%
Simplified93.1%
*-commutative93.1%
log1p-undefine93.1%
exp-to-pow92.9%
metadata-eval92.9%
pow-sqr92.9%
+-commutative92.9%
pow1/394.4%
+-commutative94.4%
pow1/398.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 97.4%
*-commutative97.8%
Simplified97.4%
(FPCore (x)
:precision binary64
(if (<= x 1.34e+154)
(+
(* -0.1111111111111111 (cbrt (/ 1.0 (pow x 5.0))))
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
(/
(+ 1.0 (- x x))
(fma
(pow x 0.3333333333333333)
(* (cbrt x) 2.0)
(pow (+ 1.0 x) 0.6666666666666666)))))
double code(double x) {
double tmp;
if (x <= 1.34e+154) {
tmp = (-0.1111111111111111 * cbrt((1.0 / pow(x, 5.0)))) + (0.3333333333333333 * cbrt((1.0 / pow(x, 2.0))));
} else {
tmp = (1.0 + (x - x)) / fma(pow(x, 0.3333333333333333), (cbrt(x) * 2.0), pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.34e+154) tmp = Float64(Float64(-0.1111111111111111 * cbrt(Float64(1.0 / (x ^ 5.0)))) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0))))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma((x ^ 0.3333333333333333), Float64(cbrt(x) * 2.0), (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := If[LessEqual[x, 1.34e+154], N[(N[(-0.1111111111111111 * N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 0.3333333333333333], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;-0.1111111111111111 \cdot \sqrt[3]{\frac{1}{{x}^{5}}} + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left({x}^{0.3333333333333333}, \sqrt[3]{x} \cdot 2, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.34000000000000001e154Initial program 6.9%
expm1-log1p-u7.8%
Applied egg-rr7.8%
Taylor expanded in x around inf 48.6%
+-commutative48.6%
fma-define48.6%
*-commutative48.6%
Simplified48.6%
Taylor expanded in x around inf 97.9%
if 1.34000000000000001e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.1%
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+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
pow1/390.5%
Applied egg-rr90.5%
*-commutative90.5%
log1p-undefine90.5%
exp-to-pow89.9%
Applied egg-rr89.9%
Taylor expanded in x around inf 89.9%
*-commutative98.8%
Simplified89.9%
(FPCore (x)
:precision binary64
(if (<= x 1.34e+154)
(+
(* -0.1111111111111111 (cbrt (/ 1.0 (pow x 5.0))))
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
(/ (+ 1.0 (- x x)) (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.34e+154) {
tmp = (-0.1111111111111111 * cbrt((1.0 / pow(x, 5.0)))) + (0.3333333333333333 * cbrt((1.0 / pow(x, 2.0))));
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.34e+154) tmp = Float64(Float64(-0.1111111111111111 * cbrt(Float64(1.0 / (x ^ 5.0)))) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0))))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.34e+154], N[(N[(-0.1111111111111111 * N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $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] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;-0.1111111111111111 \cdot \sqrt[3]{\frac{1}{{x}^{5}}} + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.34000000000000001e154Initial program 6.9%
expm1-log1p-u7.8%
Applied egg-rr7.8%
Taylor expanded in x around inf 48.6%
+-commutative48.6%
fma-define48.6%
*-commutative48.6%
Simplified48.6%
Taylor expanded in x around inf 97.9%
if 1.34000000000000001e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.1%
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+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-commutative91.7%
log1p-undefine91.7%
exp-to-pow91.4%
metadata-eval91.4%
pow-sqr91.4%
+-commutative91.4%
pow1/393.0%
+-commutative93.0%
pow1/398.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 20.0%
(FPCore (x)
:precision binary64
(if (<= x 1.34e+154)
(+
(* -0.1111111111111111 (cbrt (/ 1.0 (pow x 5.0))))
(* 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.34e+154) {
tmp = (-0.1111111111111111 * cbrt((1.0 / pow(x, 5.0)))) + (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.34e+154) {
tmp = (-0.1111111111111111 * Math.cbrt((1.0 / Math.pow(x, 5.0)))) + (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.34e+154) tmp = Float64(Float64(-0.1111111111111111 * cbrt(Float64(1.0 / (x ^ 5.0)))) + 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.34e+154], N[(N[(-0.1111111111111111 * N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $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.34 \cdot 10^{+154}:\\
\;\;\;\;-0.1111111111111111 \cdot \sqrt[3]{\frac{1}{{x}^{5}}} + 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.34000000000000001e154Initial program 6.9%
expm1-log1p-u7.8%
Applied egg-rr7.8%
Taylor expanded in x around inf 48.6%
+-commutative48.6%
fma-define48.6%
*-commutative48.6%
Simplified48.6%
Taylor expanded in x around inf 97.9%
if 1.34000000000000001e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.1%
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+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-commutative91.7%
log1p-undefine91.7%
exp-to-pow91.4%
metadata-eval91.4%
pow-sqr91.4%
+-commutative91.4%
pow1/393.0%
+-commutative93.0%
pow1/398.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 17.7%
(FPCore (x) :precision binary64 (if (<= x 1.34e+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.34e+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.34e+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.34e+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.34e+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.34 \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.34000000000000001e154Initial program 6.9%
Taylor expanded in x around inf 96.4%
if 1.34000000000000001e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.1%
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+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-commutative91.7%
log1p-undefine91.7%
exp-to-pow91.4%
metadata-eval91.4%
pow-sqr91.4%
+-commutative91.4%
pow1/393.0%
+-commutative93.0%
pow1/398.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
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 5.9%
Taylor expanded in x around inf 51.3%
(FPCore (x) :precision binary64 (+ (cbrt x) (- 0.0 (pow x 0.3333333333333333))))
double code(double x) {
return cbrt(x) + (0.0 - pow(x, 0.3333333333333333));
}
public static double code(double x) {
return Math.cbrt(x) + (0.0 - Math.pow(x, 0.3333333333333333));
}
function code(x) return Float64(cbrt(x) + Float64(0.0 - (x ^ 0.3333333333333333))) end
code[x_] := N[(N[Power[x, 1/3], $MachinePrecision] + N[(0.0 - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x} + \left(0 - {x}^{0.3333333333333333}\right)
\end{array}
Initial program 5.9%
pow1/392.0%
Applied egg-rr7.0%
Taylor expanded in x around inf 5.7%
Final simplification5.7%
(FPCore (x) :precision binary64 (pow (/ 0.037037037037037035 (pow x 2.0)) 0.3333333333333333))
double code(double x) {
return pow((0.037037037037037035 / pow(x, 2.0)), 0.3333333333333333);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.037037037037037035d0 / (x ** 2.0d0)) ** 0.3333333333333333d0
end function
public static double code(double x) {
return Math.pow((0.037037037037037035 / Math.pow(x, 2.0)), 0.3333333333333333);
}
def code(x): return math.pow((0.037037037037037035 / math.pow(x, 2.0)), 0.3333333333333333)
function code(x) return Float64(0.037037037037037035 / (x ^ 2.0)) ^ 0.3333333333333333 end
function tmp = code(x) tmp = (0.037037037037037035 / (x ^ 2.0)) ^ 0.3333333333333333; end
code[x_] := N[Power[N[(0.037037037037037035 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 0.3333333333333333], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{0.037037037037037035}{{x}^{2}}\right)}^{0.3333333333333333}
\end{array}
Initial program 5.9%
add-cbrt-cube5.9%
pow1/35.9%
pow35.9%
Applied egg-rr5.9%
Taylor expanded in x around inf 48.0%
(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 5.9%
Final simplification5.9%
(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 5.9%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.2%
fabs-neg5.2%
unpow1/35.2%
metadata-eval5.2%
pow-sqr5.2%
fabs-sqr5.2%
pow-sqr5.2%
metadata-eval5.2%
unpow1/35.2%
Simplified5.2%
Taylor expanded in x around inf 5.2%
(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 2024177
(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)))