
(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))))
(if (<= (- t_0 (cbrt x)) 1e-8)
(+
(* 0.3333333333333333 (/ 1.0 (pow (cbrt x) 2.0)))
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111))
(/ 1.0 (+ (* (cbrt x) (+ (cbrt x) t_0)) (cbrt (pow (+ 1.0 x) 2.0)))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 1e-8) {
tmp = (0.3333333333333333 * (1.0 / pow(cbrt(x), 2.0))) + (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111);
} else {
tmp = 1.0 / ((cbrt(x) * (cbrt(x) + t_0)) + cbrt(pow((1.0 + x), 2.0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 1e-8) {
tmp = (0.3333333333333333 * (1.0 / Math.pow(Math.cbrt(x), 2.0))) + (Math.cbrt((1.0 / Math.pow(x, 5.0))) * -0.1111111111111111);
} else {
tmp = 1.0 / ((Math.cbrt(x) * (Math.cbrt(x) + t_0)) + Math.cbrt(Math.pow((1.0 + x), 2.0)));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 1e-8) tmp = Float64(Float64(0.3333333333333333 * Float64(1.0 / (cbrt(x) ^ 2.0))) + Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111)); else tmp = Float64(1.0 / Float64(Float64(cbrt(x) * Float64(cbrt(x) + t_0)) + cbrt((Float64(1.0 + x) ^ 2.0)))); 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], 1e-8], N[(N[(0.3333333333333333 * N[(1.0 / N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 10^{-8}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{{\left(\sqrt[3]{x}\right)}^{2}} + \sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right) + \sqrt[3]{{\left(1 + x\right)}^{2}}}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1e-8Initial program 5.0%
add-sqr-sqrt2.7%
add-sqr-sqrt2.8%
difference-of-squares2.8%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
pow1/31.5%
sqrt-pow11.5%
metadata-eval1.5%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
Applied egg-rr2.8%
Taylor expanded in x around inf 39.8%
associate-+r+39.8%
+-commutative39.8%
unpow1/342.7%
unpow242.7%
distribute-rgt-out42.7%
unpow1/350.3%
metadata-eval50.3%
Simplified50.3%
add-sqr-sqrt50.3%
cbrt-div50.4%
metadata-eval50.4%
cbrt-prod50.3%
sqrt-div50.3%
metadata-eval50.3%
sqrt-unprod28.7%
add-sqr-sqrt30.2%
cbrt-div30.2%
metadata-eval30.2%
cbrt-prod55.7%
sqrt-div55.7%
metadata-eval55.7%
sqrt-unprod54.6%
add-sqr-sqrt98.4%
Applied egg-rr98.4%
associate-*l/98.5%
*-lft-identity98.5%
associate-/l/98.6%
unpow298.6%
Simplified98.6%
if 1e-8 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 97.9%
flip3--98.2%
div-inv98.2%
rem-cube-cbrt98.3%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
+-commutative99.8%
associate--l+99.8%
+-inverses99.8%
metadata-eval99.8%
+-commutative99.8%
fma-def99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
fma-udef99.8%
unpow299.8%
cbrt-prod99.8%
pow299.8%
Applied egg-rr99.8%
unpow299.8%
cbrt-unprod99.8%
pow299.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 0.0001)
(+
(* 0.3333333333333333 (/ 1.0 (pow (cbrt x) 2.0)))
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111))
(exp (log t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0001) {
tmp = (0.3333333333333333 * (1.0 / pow(cbrt(x), 2.0))) + (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111);
} else {
tmp = exp(log(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.0001) {
tmp = (0.3333333333333333 * (1.0 / Math.pow(Math.cbrt(x), 2.0))) + (Math.cbrt((1.0 / Math.pow(x, 5.0))) * -0.1111111111111111);
} else {
tmp = Math.exp(Math.log(t_0));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) tmp = 0.0 if (t_0 <= 0.0001) tmp = Float64(Float64(0.3333333333333333 * Float64(1.0 / (cbrt(x) ^ 2.0))) + Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111)); else tmp = exp(log(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.0001], N[(N[(0.3333333333333333 * N[(1.0 / N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[t$95$0], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0.0001:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{{\left(\sqrt[3]{x}\right)}^{2}} + \sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000005e-4Initial program 6.9%
add-sqr-sqrt2.6%
add-sqr-sqrt2.7%
difference-of-squares2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/31.4%
sqrt-pow11.4%
metadata-eval1.4%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
Applied egg-rr2.7%
Taylor expanded in x around inf 38.3%
associate-+r+38.3%
+-commutative38.3%
unpow1/341.1%
unpow241.1%
distribute-rgt-out41.1%
unpow1/351.9%
metadata-eval51.9%
Simplified51.9%
add-sqr-sqrt51.9%
cbrt-div52.0%
metadata-eval52.0%
cbrt-prod51.9%
sqrt-div51.9%
metadata-eval51.9%
sqrt-unprod27.6%
add-sqr-sqrt29.2%
cbrt-div29.2%
metadata-eval29.2%
cbrt-prod53.7%
sqrt-div53.7%
metadata-eval53.7%
sqrt-unprod52.6%
add-sqr-sqrt98.3%
Applied egg-rr98.3%
associate-*l/98.3%
*-lft-identity98.3%
associate-/l/98.4%
unpow298.4%
Simplified98.4%
if 1.00000000000000005e-4 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
add-exp-log99.6%
Applied egg-rr99.6%
Final simplification99.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 0.0001)
(+
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111)
(* 0.3333333333333333 (cbrt (* (/ 1.0 x) (/ 1.0 x)))))
(exp (log t_0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0001) {
tmp = (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * cbrt(((1.0 / x) * (1.0 / x))));
} else {
tmp = exp(log(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.0001) {
tmp = (Math.cbrt((1.0 / Math.pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * Math.cbrt(((1.0 / x) * (1.0 / x))));
} else {
tmp = Math.exp(Math.log(t_0));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) tmp = 0.0 if (t_0 <= 0.0001) tmp = Float64(Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111) + Float64(0.3333333333333333 * cbrt(Float64(Float64(1.0 / x) * Float64(1.0 / x))))); else tmp = exp(log(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.0001], 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[(N[(1.0 / x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[t$95$0], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0.0001:\\
\;\;\;\;\sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x} \cdot \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000005e-4Initial program 6.9%
add-sqr-sqrt2.6%
add-sqr-sqrt2.7%
difference-of-squares2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/31.4%
sqrt-pow11.4%
metadata-eval1.4%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
Applied egg-rr2.7%
Taylor expanded in x around inf 38.3%
associate-+r+38.3%
+-commutative38.3%
unpow1/341.1%
unpow241.1%
distribute-rgt-out41.1%
unpow1/351.9%
metadata-eval51.9%
Simplified51.9%
inv-pow51.9%
unpow-prod-down52.4%
inv-pow52.4%
inv-pow52.4%
Applied egg-rr52.4%
if 1.00000000000000005e-4 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
add-exp-log99.6%
Applied egg-rr99.6%
Final simplification74.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 0.0001)
(+
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111)
(* 0.3333333333333333 (cbrt (* (/ 1.0 x) (/ 1.0 x)))))
t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0001) {
tmp = (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * cbrt(((1.0 / x) * (1.0 / x))));
} 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.0001) {
tmp = (Math.cbrt((1.0 / Math.pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * Math.cbrt(((1.0 / x) * (1.0 / x))));
} 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.0001) tmp = Float64(Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111) + Float64(0.3333333333333333 * cbrt(Float64(Float64(1.0 / x) * Float64(1.0 / x))))); 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.0001], 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[(N[(1.0 / x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0.0001:\\
\;\;\;\;\sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x} \cdot \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000005e-4Initial program 6.9%
add-sqr-sqrt2.6%
add-sqr-sqrt2.7%
difference-of-squares2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/31.4%
sqrt-pow11.4%
metadata-eval1.4%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
Applied egg-rr2.7%
Taylor expanded in x around inf 38.3%
associate-+r+38.3%
+-commutative38.3%
unpow1/341.1%
unpow241.1%
distribute-rgt-out41.1%
unpow1/351.9%
metadata-eval51.9%
Simplified51.9%
inv-pow51.9%
unpow-prod-down52.4%
inv-pow52.4%
inv-pow52.4%
Applied egg-rr52.4%
if 1.00000000000000005e-4 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
Final simplification74.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 0.0001)
(+
(* (cbrt (/ 1.0 (pow x 5.0))) -0.1111111111111111)
(* 0.3333333333333333 (/ 1.0 (cbrt (* x x)))))
t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0001) {
tmp = (cbrt((1.0 / pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * (1.0 / cbrt((x * x))));
} 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.0001) {
tmp = (Math.cbrt((1.0 / Math.pow(x, 5.0))) * -0.1111111111111111) + (0.3333333333333333 * (1.0 / Math.cbrt((x * x))));
} 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.0001) tmp = Float64(Float64(cbrt(Float64(1.0 / (x ^ 5.0))) * -0.1111111111111111) + Float64(0.3333333333333333 * Float64(1.0 / cbrt(Float64(x * x))))); 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.0001], N[(N[(N[Power[N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision] + N[(0.3333333333333333 * N[(1.0 / N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0.0001:\\
\;\;\;\;\sqrt[3]{\frac{1}{{x}^{5}}} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot \frac{1}{\sqrt[3]{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000005e-4Initial program 6.9%
add-sqr-sqrt2.6%
add-sqr-sqrt2.7%
difference-of-squares2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/31.4%
sqrt-pow11.4%
metadata-eval1.4%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
Applied egg-rr2.7%
Taylor expanded in x around inf 38.3%
associate-+r+38.3%
+-commutative38.3%
unpow1/341.1%
unpow241.1%
distribute-rgt-out41.1%
unpow1/351.9%
metadata-eval51.9%
Simplified51.9%
clear-num51.9%
cbrt-div52.0%
metadata-eval52.0%
Applied egg-rr52.0%
unpow252.0%
/-rgt-identity52.0%
unpow252.0%
Simplified52.0%
if 1.00000000000000005e-4 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
Final simplification74.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x))))
(if (<= t_0 0.0001)
(+
(* 0.3333333333333333 (cbrt (/ 1.0 (* x x))))
(* -0.1111111111111111 (cbrt (pow x -5.0))))
t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0001) {
tmp = (0.3333333333333333 * cbrt((1.0 / (x * x)))) + (-0.1111111111111111 * cbrt(pow(x, -5.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.0001) {
tmp = (0.3333333333333333 * Math.cbrt((1.0 / (x * x)))) + (-0.1111111111111111 * Math.cbrt(Math.pow(x, -5.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.0001) tmp = Float64(Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))) + Float64(-0.1111111111111111 * cbrt((x ^ -5.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.0001], N[(N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[(-0.1111111111111111 * N[Power[N[Power[x, -5.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 0.0001:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}} + -0.1111111111111111 \cdot \sqrt[3]{{x}^{-5}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 1.00000000000000005e-4Initial program 6.9%
add-sqr-sqrt2.6%
add-sqr-sqrt2.7%
difference-of-squares2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
pow1/31.4%
sqrt-pow11.4%
metadata-eval1.4%
pow1/32.7%
sqrt-pow12.7%
metadata-eval2.7%
Applied egg-rr2.7%
Taylor expanded in x around inf 38.3%
associate-+r+38.3%
+-commutative38.3%
unpow1/341.1%
unpow241.1%
distribute-rgt-out41.1%
unpow1/351.9%
metadata-eval51.9%
Simplified51.9%
expm1-log1p-u51.9%
expm1-udef51.1%
pow-flip51.1%
metadata-eval51.1%
Applied egg-rr51.1%
expm1-def51.9%
expm1-log1p51.9%
Simplified51.9%
if 1.00000000000000005e-4 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
Final simplification74.5%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (* (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 / ((cbrt(x) * (cbrt(x) + t_0)) + pow(t_0, 2.0));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / ((Math.cbrt(x) * (Math.cbrt(x) + t_0)) + Math.pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64(Float64(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[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $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}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right) + {t_0}^{2}}
\end{array}
\end{array}
Initial program 50.7%
flip3--50.9%
div-inv50.9%
rem-cube-cbrt51.0%
rem-cube-cbrt52.4%
cbrt-unprod52.4%
pow252.4%
distribute-rgt-out52.4%
+-commutative52.4%
Applied egg-rr52.4%
associate-*r/52.4%
*-rgt-identity52.4%
+-commutative52.4%
associate--l+74.7%
+-inverses74.7%
metadata-eval74.7%
+-commutative74.7%
fma-def74.8%
+-commutative74.8%
+-commutative74.8%
Simplified74.8%
fma-udef74.7%
unpow274.7%
cbrt-prod99.2%
pow299.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= (- (cbrt (+ 1.0 x)) (cbrt x)) 5e-7) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) (- (cbrt (- (/ 1.0 (- 1.0 x)) (/ x (/ (- 1.0 x) x)))) (cbrt x))))
double code(double x) {
double tmp;
if ((cbrt((1.0 + x)) - cbrt(x)) <= 5e-7) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = cbrt(((1.0 / (1.0 - x)) - (x / ((1.0 - x) / x)))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((Math.cbrt((1.0 + x)) - Math.cbrt(x)) <= 5e-7) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = Math.cbrt(((1.0 / (1.0 - x)) - (x / ((1.0 - x) / x)))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) <= 5e-7) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(cbrt(Float64(Float64(1.0 / Float64(1.0 - x)) - Float64(x / Float64(Float64(1.0 - x) / x)))) - cbrt(x)); end return tmp end
code[x_] := If[LessEqual[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-7], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{1 - x} - \frac{x}{\frac{1 - x}{x}}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.99999999999999977e-7Initial program 5.6%
add-sqr-sqrt2.6%
add-sqr-sqrt2.8%
difference-of-squares2.8%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
pow1/31.5%
sqrt-pow11.5%
metadata-eval1.5%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
Applied egg-rr2.8%
Taylor expanded in x around inf 47.1%
unpow1/350.3%
unpow250.3%
Simplified50.3%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.8%
add-exp-log96.5%
pow1/396.5%
log-pow96.5%
+-commutative96.5%
log1p-udef96.5%
Applied egg-rr96.5%
*-commutative96.5%
exp-prod96.5%
unpow1/396.5%
Simplified96.5%
log1p-udef96.5%
add-exp-log98.8%
flip3-+98.7%
metadata-eval98.7%
metadata-eval98.7%
*-un-lft-identity98.7%
Applied egg-rr98.7%
metadata-eval98.7%
metadata-eval98.7%
*-un-lft-identity98.7%
flip3-+98.8%
flip-+98.8%
metadata-eval98.8%
div-sub98.8%
Applied egg-rr98.8%
associate-/l*98.8%
Simplified98.8%
Final simplification73.8%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 5e-7) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 5e-7) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} 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 <= 5e-7) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} 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 <= 5e-7) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); 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, 5e-7], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 4.99999999999999977e-7Initial program 5.6%
add-sqr-sqrt2.6%
add-sqr-sqrt2.8%
difference-of-squares2.8%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
pow1/31.5%
sqrt-pow11.5%
metadata-eval1.5%
pow1/32.8%
sqrt-pow12.8%
metadata-eval2.8%
Applied egg-rr2.8%
Taylor expanded in x around inf 47.1%
unpow1/350.3%
unpow250.3%
Simplified50.3%
if 4.99999999999999977e-7 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.8%
Final simplification73.8%
(FPCore (x)
:precision binary64
(if (or (<= x -1.05) (not (<= x 1.02)))
(* 0.3333333333333333 (cbrt (/ 1.0 (* x x))))
(-
(+ 1.0 (* x (+ 0.3333333333333333 (* x -0.1111111111111111))))
(cbrt x))))
double code(double x) {
double tmp;
if ((x <= -1.05) || !(x <= 1.02)) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.05) || !(x <= 1.02)) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = (1.0 + (x * (0.3333333333333333 + (x * -0.1111111111111111)))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.05) || !(x <= 1.02)) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(Float64(1.0 + Float64(x * Float64(0.3333333333333333 + Float64(x * -0.1111111111111111)))) - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -1.05], N[Not[LessEqual[x, 1.02]], $MachinePrecision]], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * N[(0.3333333333333333 + N[(x * -0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \lor \neg \left(x \leq 1.02\right):\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(0.3333333333333333 + x \cdot -0.1111111111111111\right)\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1.05000000000000004 or 1.02 < x Initial program 8.0%
add-sqr-sqrt3.1%
add-sqr-sqrt3.3%
difference-of-squares3.2%
pow1/33.2%
sqrt-pow13.2%
metadata-eval3.2%
pow1/33.2%
sqrt-pow13.2%
metadata-eval3.2%
pow1/31.9%
sqrt-pow11.9%
metadata-eval1.9%
pow1/33.2%
sqrt-pow13.2%
metadata-eval3.2%
Applied egg-rr3.2%
Taylor expanded in x around inf 47.1%
unpow1/350.2%
unpow250.2%
Simplified50.2%
if -1.05000000000000004 < x < 1.02Initial program 99.9%
Taylor expanded in x around 0 96.8%
+-commutative96.8%
unpow296.8%
associate-*r*96.8%
distribute-rgt-out96.8%
*-commutative96.8%
Simplified96.8%
Final simplification71.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.24))) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) (/ 1.0 (+ 1.0 (* x 0.6666666666666666)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 0.24)) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 / (1.0 + (x * 0.6666666666666666));
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 0.24)) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 / (1.0 + (x * 0.6666666666666666));
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.24)) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(1.0 / Float64(1.0 + Float64(x * 0.6666666666666666))); end return tmp end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.24]], $MachinePrecision]], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.24\right):\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + x \cdot 0.6666666666666666}\\
\end{array}
\end{array}
if x < -1 or 0.23999999999999999 < x Initial program 8.6%
add-sqr-sqrt3.8%
add-sqr-sqrt3.9%
difference-of-squares3.9%
pow1/33.9%
sqrt-pow13.9%
metadata-eval3.9%
pow1/33.9%
sqrt-pow13.9%
metadata-eval3.9%
pow1/32.6%
sqrt-pow12.6%
metadata-eval2.6%
pow1/33.9%
sqrt-pow13.9%
metadata-eval3.9%
Applied egg-rr3.9%
Taylor expanded in x around inf 46.9%
unpow1/350.0%
unpow250.0%
Simplified50.0%
if -1 < x < 0.23999999999999999Initial program 100.0%
flip3--99.9%
div-inv99.9%
rem-cube-cbrt99.9%
rem-cube-cbrt99.9%
cbrt-unprod99.9%
pow299.9%
distribute-rgt-out99.9%
+-commutative99.9%
Applied egg-rr99.9%
associate-*r/99.9%
*-rgt-identity99.9%
+-commutative99.9%
associate--l+99.9%
+-inverses99.9%
metadata-eval99.9%
+-commutative99.9%
fma-def99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
unpow299.9%
unpow299.9%
+-commutative99.9%
expm1-log1p-u99.9%
expm1-udef99.9%
+-commutative99.9%
unpow299.9%
cbrt-prod99.9%
pow299.9%
Applied egg-rr99.9%
expm1-def99.9%
expm1-log1p99.9%
Simplified99.9%
Taylor expanded in x around 0 91.3%
Final simplification69.1%
(FPCore (x) :precision binary64 (if (or (<= x -1.05) (not (<= x 1.0))) (* 0.3333333333333333 (cbrt (/ 1.0 (* x x)))) (- (+ 1.0 (* x 0.3333333333333333)) (cbrt x))))
double code(double x) {
double tmp;
if ((x <= -1.05) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * cbrt((1.0 / (x * x)));
} else {
tmp = (1.0 + (x * 0.3333333333333333)) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -1.05) || !(x <= 1.0)) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / (x * x)));
} else {
tmp = (1.0 + (x * 0.3333333333333333)) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -1.05) || !(x <= 1.0)) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / Float64(x * x)))); else tmp = Float64(Float64(1.0 + Float64(x * 0.3333333333333333)) - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -1.05], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(0.3333333333333333 * N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot 0.3333333333333333\right) - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -1.05000000000000004 or 1 < x Initial program 8.0%
add-sqr-sqrt3.1%
add-sqr-sqrt3.3%
difference-of-squares3.2%
pow1/33.2%
sqrt-pow13.2%
metadata-eval3.2%
pow1/33.2%
sqrt-pow13.2%
metadata-eval3.2%
pow1/31.9%
sqrt-pow11.9%
metadata-eval1.9%
pow1/33.2%
sqrt-pow13.2%
metadata-eval3.2%
Applied egg-rr3.2%
Taylor expanded in x around inf 47.1%
unpow1/350.2%
unpow250.2%
Simplified50.2%
if -1.05000000000000004 < x < 1Initial program 99.9%
Taylor expanded in x around 0 96.8%
+-commutative96.8%
unpow296.8%
associate-*r*96.8%
distribute-rgt-out96.8%
*-commutative96.8%
Simplified96.8%
Taylor expanded in x around 0 96.3%
*-commutative96.3%
Simplified96.3%
Final simplification71.6%
(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 50.7%
Taylor expanded in x around inf 3.7%
Final simplification3.7%
(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 50.7%
Taylor expanded in x around 0 45.6%
Final simplification45.6%
herbie shell --seed 2023280
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))