
(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 15 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 (cbrt (sqrt x)))) (/ (+ 1.0 (- x x)) (fma (cbrt x) (+ t_0 (* t_1 t_1)) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(sqrt(x));
return (1.0 + (x - x)) / fma(cbrt(x), (t_0 + (t_1 * t_1)), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = cbrt(sqrt(x)) return Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(t_0 + Float64(t_1 * t_1)), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sqrt[x], $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(t$95$0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{\sqrt{x}}\\
\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, t\_0 + t\_1 \cdot t\_1, {t\_0}^{2}\right)}
\end{array}
\end{array}
Initial program 7.4%
add-sqr-sqrt7.3%
pow27.3%
pow1/38.6%
sqrt-pow18.6%
metadata-eval8.6%
Applied egg-rr8.6%
pow-pow8.6%
metadata-eval8.6%
pow1/37.4%
flip3--7.7%
div-inv7.7%
rem-cube-cbrt7.0%
rem-cube-cbrt8.6%
+-commutative8.6%
distribute-rgt-out8.6%
+-commutative8.6%
fma-def8.6%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
+-commutative8.6%
associate--l+98.5%
+-commutative98.5%
+-commutative98.5%
Simplified98.5%
pow1/394.6%
add-sqr-sqrt94.6%
unpow-prod-down94.6%
pow-prod-up94.6%
metadata-eval94.6%
Applied egg-rr94.6%
*-rgt-identity94.6%
metadata-eval94.6%
pow-sqr94.6%
unpow1/396.0%
*-rgt-identity96.0%
unpow1/398.6%
*-rgt-identity98.6%
Simplified98.6%
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.4%
add-exp-log7.1%
Applied egg-rr7.1%
rem-exp-log7.4%
flip3--7.7%
div-inv7.7%
rem-cube-cbrt7.0%
+-commutative7.0%
rem-cube-cbrt8.6%
pow28.6%
+-commutative8.6%
+-commutative8.6%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
associate--l+98.5%
+-inverses98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x)
:precision binary64
(if (<= x 500000000.0)
(/
(+ 1.0 (- x x))
(+
(exp (* 0.6666666666666666 (log1p x)))
(+ (pow (cbrt x) 2.0) (cbrt (* x (+ 1.0 x))))))
(if (<= x 1.35e+154)
(+
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0)))))
double code(double x) {
double tmp;
if (x <= 500000000.0) {
tmp = (1.0 + (x - x)) / (exp((0.6666666666666666 * log1p(x))) + (pow(cbrt(x), 2.0) + cbrt((x * (1.0 + x)))));
} else if (x <= 1.35e+154) {
tmp = (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * cbrt((1.0 / pow(x, 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 <= 500000000.0) tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(exp(Float64(0.6666666666666666 * log1p(x))) + Float64((cbrt(x) ^ 2.0) + cbrt(Float64(x * Float64(1.0 + x)))))); elseif (x <= 1.35e+154) tmp = Float64(Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 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, 500000000.0], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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], If[LessEqual[x, 1.35e+154], N[(N[(N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * -0.1111111111111111), $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[(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 500000000:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{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{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{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 < 5e8Initial program 84.2%
add-sqr-sqrt83.5%
pow283.5%
pow1/383.2%
sqrt-pow183.1%
metadata-eval83.1%
Applied egg-rr83.1%
pow-pow84.1%
metadata-eval84.1%
pow1/384.2%
flip3--84.3%
div-inv84.3%
rem-cube-cbrt85.6%
rem-cube-cbrt98.9%
+-commutative98.9%
distribute-rgt-out98.6%
+-commutative98.6%
fma-def98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
+-commutative98.7%
associate--l+98.7%
+-commutative98.7%
+-commutative98.7%
Simplified98.7%
fma-udef98.6%
+-commutative98.6%
+-commutative98.6%
distribute-rgt-in98.9%
+-commutative98.9%
associate-+r+98.7%
pow298.7%
cbrt-unprod99.3%
+-commutative99.3%
Applied egg-rr99.3%
associate-+l+99.2%
*-commutative99.2%
Simplified99.2%
add-exp-log99.0%
pow-to-exp98.7%
rem-log-exp98.7%
*-commutative98.7%
pow1/398.5%
+-commutative98.5%
log-pow98.4%
+-commutative98.4%
log1p-udef98.4%
Applied egg-rr98.4%
associate-*r*98.4%
metadata-eval98.4%
Simplified98.4%
if 5e8 < x < 1.35000000000000003e154Initial program 4.5%
add-sqr-sqrt4.8%
add-sqr-sqrt4.5%
difference-of-squares4.5%
pow1/34.5%
sqrt-pow14.5%
metadata-eval4.5%
pow1/34.5%
sqrt-pow14.5%
metadata-eval4.5%
pow1/32.6%
sqrt-pow12.6%
metadata-eval2.6%
pow1/34.5%
sqrt-pow14.5%
metadata-eval4.5%
Applied egg-rr4.5%
Taylor expanded in x around inf 91.8%
associate-+r+91.8%
distribute-rgt-out91.8%
unpow1/391.8%
metadata-eval91.8%
unpow1/398.7%
Simplified98.7%
if 1.35000000000000003e154 < 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-def4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+92.1%
+-inverses92.1%
metadata-eval92.1%
+-commutative92.1%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 20.0%
Final simplification61.8%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ (+ 1.0 (- x x)) (+ (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 + (x - x)) / (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 + (x - x)) / (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(Float64(1.0 + Float64(x - x)) / 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[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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 + \left(x - x\right)}{{t\_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}
\end{array}
\end{array}
Initial program 7.4%
add-sqr-sqrt7.3%
pow27.3%
pow1/38.6%
sqrt-pow18.6%
metadata-eval8.6%
Applied egg-rr8.6%
pow-pow8.6%
metadata-eval8.6%
pow1/37.4%
flip3--7.7%
div-inv7.7%
rem-cube-cbrt7.0%
rem-cube-cbrt8.6%
+-commutative8.6%
distribute-rgt-out8.6%
+-commutative8.6%
fma-def8.6%
Applied egg-rr8.6%
associate-*r/8.6%
*-rgt-identity8.6%
+-commutative8.6%
associate--l+98.5%
+-commutative98.5%
+-commutative98.5%
Simplified98.5%
fma-udef98.5%
+-commutative98.5%
+-commutative98.5%
distribute-rgt-in98.5%
+-commutative98.5%
distribute-rgt-in98.5%
+-commutative98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x)
:precision binary64
(if (<= x 260000000.0)
(- (/ (cbrt (fma x x -1.0)) (cbrt (+ x -1.0))) (cbrt x))
(if (<= x 1.35e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0)))))
double code(double x) {
double tmp;
if (x <= 260000000.0) {
tmp = (cbrt(fma(x, x, -1.0)) / cbrt((x + -1.0))) - cbrt(x);
} 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) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 260000000.0) tmp = Float64(Float64(cbrt(fma(x, x, -1.0)) / cbrt(Float64(x + -1.0))) - cbrt(x)); 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) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 260000000.0], N[(N[(N[Power[N[(x * x + -1.0), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(x + -1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $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] + 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 260000000:\\
\;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(x, x, -1\right)}}{\sqrt[3]{x + -1}} - \sqrt[3]{x}\\
\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} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 2.6e8Initial program 84.2%
flip-+84.5%
cbrt-div86.1%
metadata-eval86.1%
fma-neg86.1%
metadata-eval86.1%
sub-neg86.1%
metadata-eval86.1%
Applied egg-rr86.1%
if 2.6e8 < x < 1.35000000000000003e154Initial program 4.5%
add-sqr-sqrt4.8%
add-sqr-sqrt4.5%
difference-of-squares4.5%
pow1/34.5%
sqrt-pow14.5%
metadata-eval4.5%
pow1/34.5%
sqrt-pow14.5%
metadata-eval4.5%
pow1/32.6%
sqrt-pow12.6%
metadata-eval2.6%
pow1/34.5%
sqrt-pow14.5%
metadata-eval4.5%
Applied egg-rr4.5%
Taylor expanded in x around inf 91.4%
unpow1/398.2%
Simplified98.2%
if 1.35000000000000003e154 < 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-def4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+92.1%
+-inverses92.1%
metadata-eval92.1%
+-commutative92.1%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 20.0%
Final simplification61.1%
(FPCore (x)
:precision binary64
(if (<= x 1.35e+154)
(+
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.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 = (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * cbrt((1.0 / pow(x, 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.35e+154) tmp = Float64(Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111) + Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 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.35e+154], N[(N[(N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * -0.1111111111111111), $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[(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}:\\
\;\;\;\;\sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{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.35000000000000003e154Initial program 9.8%
add-sqr-sqrt10.0%
add-sqr-sqrt9.7%
difference-of-squares9.7%
pow1/39.7%
sqrt-pow19.7%
metadata-eval9.7%
pow1/39.7%
sqrt-pow19.7%
metadata-eval9.7%
pow1/38.0%
sqrt-pow18.0%
metadata-eval8.0%
pow1/39.9%
sqrt-pow19.9%
metadata-eval9.9%
Applied egg-rr9.9%
Taylor expanded in x around inf 89.0%
associate-+r+89.0%
distribute-rgt-out89.0%
unpow1/389.0%
metadata-eval89.0%
unpow1/395.4%
Simplified95.4%
if 1.35000000000000003e154 < 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-def4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+92.1%
+-inverses92.1%
metadata-eval92.1%
+-commutative92.1%
exp-prod90.9%
Simplified90.9%
Taylor expanded in x around 0 20.0%
Final simplification60.0%
(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 6.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 73.7%
Final simplification9.2%
(FPCore (x) :precision binary64 (if (<= x 260000000.0) (- (/ (cbrt (fma x x -1.0)) (cbrt (+ x -1.0))) (cbrt x)) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 260000000.0) {
tmp = (cbrt(fma(x, x, -1.0)) / cbrt((x + -1.0))) - cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 260000000.0) tmp = Float64(Float64(cbrt(fma(x, x, -1.0)) / cbrt(Float64(x + -1.0))) - cbrt(x)); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 260000000.0], N[(N[(N[Power[N[(x * x + -1.0), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(x + -1.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 260000000:\\
\;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(x, x, -1\right)}}{\sqrt[3]{x + -1}} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 2.6e8Initial program 84.2%
flip-+84.5%
cbrt-div86.1%
metadata-eval86.1%
fma-neg86.1%
metadata-eval86.1%
sub-neg86.1%
metadata-eval86.1%
Applied egg-rr86.1%
if 2.6e8 < x Initial program 4.6%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/32.3%
sqrt-pow12.3%
metadata-eval2.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 49.3%
unpow1/352.8%
Simplified52.8%
Final simplification54.0%
(FPCore (x)
:precision binary64
(if (<= x 260000000.0)
(+
(pow (+ 1.0 x) 0.3333333333333333)
(- (pow (pow x 0.16666666666666666) 2.0)))
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 260000000.0) {
tmp = pow((1.0 + x), 0.3333333333333333) + -pow(pow(x, 0.16666666666666666), 2.0);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 260000000.0) {
tmp = Math.pow((1.0 + x), 0.3333333333333333) + -Math.pow(Math.pow(x, 0.16666666666666666), 2.0);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 260000000.0) tmp = Float64((Float64(1.0 + x) ^ 0.3333333333333333) + Float64(-((x ^ 0.16666666666666666) ^ 2.0))); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 260000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] + (-N[Power[N[Power[x, 0.16666666666666666], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 260000000:\\
\;\;\;\;{\left(1 + x\right)}^{0.3333333333333333} + \left(-{\left({x}^{0.16666666666666666}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 2.6e8Initial program 84.2%
add-sqr-sqrt83.5%
pow283.5%
pow1/383.2%
sqrt-pow183.1%
metadata-eval83.1%
Applied egg-rr83.1%
pow1/384.5%
Applied egg-rr85.8%
if 2.6e8 < x Initial program 4.6%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/32.3%
sqrt-pow12.3%
metadata-eval2.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 49.3%
unpow1/352.8%
Simplified52.8%
Final simplification54.0%
(FPCore (x) :precision binary64 (if (<= x 16500000.0) (+ (pow (sqrt (+ 1.0 x)) 0.6666666666666666) (- (cbrt x))) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 16500000.0) {
tmp = pow(sqrt((1.0 + x)), 0.6666666666666666) + -cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 16500000.0) {
tmp = Math.pow(Math.sqrt((1.0 + x)), 0.6666666666666666) + -Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 16500000.0) tmp = Float64((sqrt(Float64(1.0 + x)) ^ 0.6666666666666666) + Float64(-cbrt(x))); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 16500000.0], N[(N[Power[N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision], 0.6666666666666666], $MachinePrecision] + (-N[Power[x, 1/3], $MachinePrecision])), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 16500000:\\
\;\;\;\;{\left(\sqrt{1 + x}\right)}^{0.6666666666666666} + \left(-\sqrt[3]{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 1.65e7Initial program 84.2%
pow1/384.5%
add-sqr-sqrt84.8%
unpow-prod-down85.1%
pow-prod-up84.7%
metadata-eval84.7%
Applied egg-rr84.7%
if 1.65e7 < x Initial program 4.6%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/32.3%
sqrt-pow12.3%
metadata-eval2.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 49.3%
unpow1/352.8%
Simplified52.8%
Final simplification53.9%
(FPCore (x) :precision binary64 (if (<= x 260000000.0) (- (exp (* (log1p x) 0.3333333333333333)) (cbrt x)) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 260000000.0) {
tmp = exp((log1p(x) * 0.3333333333333333)) - cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 260000000.0) {
tmp = Math.exp((Math.log1p(x) * 0.3333333333333333)) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 260000000.0) tmp = Float64(exp(Float64(log1p(x) * 0.3333333333333333)) - cbrt(x)); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 260000000.0], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 260000000:\\
\;\;\;\;e^{\mathsf{log1p}\left(x\right) \cdot 0.3333333333333333} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 2.6e8Initial program 84.2%
pow1/384.5%
pow-to-exp84.6%
+-commutative84.6%
log1p-udef84.6%
Applied egg-rr84.6%
if 2.6e8 < x Initial program 4.6%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/32.3%
sqrt-pow12.3%
metadata-eval2.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 49.3%
unpow1/352.8%
Simplified52.8%
Final simplification53.9%
(FPCore (x) :precision binary64 (if (<= x 55000000.0) (- (cbrt (+ 1.0 x)) (cbrt x)) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 55000000.0) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 55000000.0) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 55000000.0) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 55000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 55000000:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 5.5e7Initial program 84.2%
if 5.5e7 < x Initial program 4.6%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/32.3%
sqrt-pow12.3%
metadata-eval2.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 49.3%
unpow1/352.8%
Simplified52.8%
Final simplification53.9%
(FPCore (x) :precision binary64 (if (<= x 16500000.0) (- (pow (+ 1.0 x) 0.3333333333333333) (cbrt x)) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 16500000.0) {
tmp = pow((1.0 + x), 0.3333333333333333) - cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 16500000.0) {
tmp = Math.pow((1.0 + x), 0.3333333333333333) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 16500000.0) tmp = Float64((Float64(1.0 + x) ^ 0.3333333333333333) - cbrt(x)); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 16500000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 16500000:\\
\;\;\;\;{\left(1 + x\right)}^{0.3333333333333333} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 1.65e7Initial program 84.2%
pow1/384.5%
Applied egg-rr84.5%
if 1.65e7 < x Initial program 4.6%
add-sqr-sqrt4.4%
add-sqr-sqrt4.6%
difference-of-squares4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
pow1/32.3%
sqrt-pow12.3%
metadata-eval2.3%
pow1/34.6%
sqrt-pow14.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 49.3%
unpow1/352.8%
Simplified52.8%
Final simplification53.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.4%
Taylor expanded in x around inf 4.1%
Final simplification4.1%
(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.4%
Taylor expanded in x around 0 6.4%
Final simplification6.4%
(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 2024041
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:herbie-target
(/ 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)))