
(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)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (/ t_0 (/ 1.0 t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), (t_0 / (1.0 / t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), Float64(t_0 / Float64(1.0 / 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[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(t$95$0 / N[(1.0 / t$95$0), $MachinePrecision]), $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, \frac{t\_0}{\frac{1}{t\_0}}\right)}
\end{array}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) t_1)))
(/ 1.0 (fma (cbrt x) t_1 (pow (+ 1.0 x) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = cbrt(x) + t_0;
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * t_1));
} else {
tmp = 1.0 / fma(cbrt(x), t_1, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(cbrt(x) + t_0) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * t_1))); else tmp = Float64(1.0 / fma(cbrt(x), t_1, (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 5e-11], N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} + t\_0\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_1, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.8%
rem-cube-cbrt5.4%
+-commutative5.4%
distribute-rgt-out5.4%
+-commutative5.4%
fma-define5.4%
add-exp-log5.4%
Applied egg-rr5.3%
associate-*r/5.3%
*-rgt-identity5.3%
+-commutative5.3%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around inf 47.5%
unpow1/349.7%
Simplified49.7%
fma-undefine49.7%
+-commutative49.7%
unpow249.7%
cbrt-prod98.4%
pow298.4%
Applied egg-rr98.4%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 66.9%
flip3--72.3%
div-inv72.3%
rem-cube-cbrt66.9%
rem-cube-cbrt98.6%
+-commutative98.6%
distribute-rgt-out99.0%
+-commutative99.0%
fma-define99.0%
add-exp-log98.6%
Applied egg-rr98.0%
associate-*r/98.0%
*-rgt-identity98.0%
+-commutative98.0%
associate--l+98.0%
+-inverses98.0%
metadata-eval98.0%
+-commutative98.0%
exp-prod98.0%
Simplified98.0%
pow-exp98.0%
*-commutative98.0%
log1p-undefine98.0%
exp-to-pow98.5%
metadata-eval98.5%
pow-sqr98.6%
pow1/399.2%
pow1/399.0%
cbrt-unprod99.3%
pow299.3%
+-commutative99.3%
Applied egg-rr99.3%
pow1/398.6%
pow-pow98.5%
metadata-eval98.5%
Applied egg-rr98.5%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-11)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))
(- (/ (cbrt (fma x x -1.0)) (cbrt (+ x -1.0))) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-11) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
} else {
tmp = (cbrt(fma(x, x, -1.0)) / cbrt((x + -1.0))) - cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-11) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); else tmp = Float64(Float64(cbrt(fma(x, x, -1.0)) / cbrt(Float64(x + -1.0))) - cbrt(x)); 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], 5e-11], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t\_0 - \sqrt[3]{x} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(x, x, -1\right)}}{\sqrt[3]{x + -1}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000018e-11Initial program 4.3%
flip3--4.3%
div-inv4.3%
rem-cube-cbrt3.8%
rem-cube-cbrt5.4%
+-commutative5.4%
distribute-rgt-out5.4%
+-commutative5.4%
fma-define5.4%
add-exp-log5.4%
Applied egg-rr5.3%
associate-*r/5.3%
*-rgt-identity5.3%
+-commutative5.3%
associate--l+93.0%
+-inverses93.0%
metadata-eval93.0%
+-commutative93.0%
exp-prod92.2%
Simplified92.2%
Taylor expanded in x around 0 20.0%
if 5.00000000000000018e-11 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 66.9%
flip-+67.0%
cbrt-div67.6%
metadata-eval67.6%
fma-neg67.6%
metadata-eval67.6%
sub-neg67.6%
metadata-eval67.6%
Applied egg-rr67.6%
Final simplification22.6%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (/ 1.0 (pow (/ 1.0 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), (1.0 / pow((1.0 / 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), Float64(1.0 / (Float64(1.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[(1.0 / N[Power[N[(1.0 / t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $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, \frac{1}{{\left(\frac{1}{t\_0}\right)}^{2}}\right)}
\end{array}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Applied egg-rr98.4%
pow298.4%
pow1/393.1%
+-commutative93.1%
pow1/398.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {t\_0}^{2}\right)}
\end{array}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
pow-exp93.2%
*-commutative93.2%
log1p-undefine93.2%
exp-to-pow93.0%
metadata-eval93.0%
pow-sqr93.1%
pow1/394.5%
pow1/398.4%
cbrt-unprod52.4%
pow252.4%
+-commutative52.4%
Applied egg-rr52.4%
unpow252.4%
cbrt-prod98.4%
pow298.4%
Applied egg-rr98.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 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Applied egg-rr98.4%
fma-undefine98.4%
div-inv98.4%
remove-double-div98.4%
cbrt-prod52.4%
unpow252.4%
+-commutative52.4%
unpow252.4%
cbrt-prod98.4%
pow298.4%
+-commutative98.4%
+-commutative98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x) :precision binary64 (/ 1.0 (+ (pow (cbrt x) 2.0) (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))))))
double code(double x) {
return 1.0 / (pow(cbrt(x), 2.0) + (cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))));
}
public static double code(double x) {
return 1.0 / (Math.pow(Math.cbrt(x), 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
}
function code(x) return Float64(1.0 / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))) end
code[x_] := N[(1.0 / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $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]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Taylor expanded in x around inf 47.8%
unpow1/349.9%
Simplified49.9%
fma-undefine49.9%
+-commutative49.9%
unpow249.9%
cbrt-prod95.9%
pow295.9%
Applied egg-rr95.9%
Final simplification95.9%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (/ 1.5 x) t_0)))
double code(double x) {
double t_0 = cbrt((1.0 + x)) - cbrt(x);
double tmp;
if (t_0 <= 0.0) {
tmp = 1.5 / 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.0) {
tmp = 1.5 / 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.0) tmp = Float64(1.5 / 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.0], N[(1.5 / x), $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:\\
\;\;\;\;\frac{1.5}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.8%
rem-cube-cbrt4.6%
+-commutative4.6%
distribute-rgt-out4.6%
+-commutative4.6%
fma-define4.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
+-commutative4.6%
associate--l+92.9%
+-inverses92.9%
metadata-eval92.9%
+-commutative92.9%
exp-prod92.2%
Simplified92.2%
Applied egg-rr98.4%
Taylor expanded in x around 0 7.6%
Taylor expanded in x around inf 7.6%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 61.0%
Final simplification10.9%
(FPCore (x) :precision binary64 (if (<= x 4.1e+20) (- (pow (cbrt (cbrt (+ 1.0 x))) 3.0) (cbrt x)) (/ 1.5 x)))
double code(double x) {
double tmp;
if (x <= 4.1e+20) {
tmp = pow(cbrt(cbrt((1.0 + x))), 3.0) - cbrt(x);
} else {
tmp = 1.5 / x;
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 4.1e+20) {
tmp = Math.pow(Math.cbrt(Math.cbrt((1.0 + x))), 3.0) - Math.cbrt(x);
} else {
tmp = 1.5 / x;
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 4.1e+20) tmp = Float64((cbrt(cbrt(Float64(1.0 + x))) ^ 3.0) - cbrt(x)); else tmp = Float64(1.5 / x); end return tmp end
code[x_] := If[LessEqual[x, 4.1e+20], N[(N[Power[N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(1.5 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.1 \cdot 10^{+20}:\\
\;\;\;\;{\left(\sqrt[3]{\sqrt[3]{1 + x}}\right)}^{3} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1.5}{x}\\
\end{array}
\end{array}
if x < 4.1e20Initial program 47.3%
add-cube-cbrt49.0%
pow349.4%
Applied egg-rr49.4%
if 4.1e20 < 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-prod92.1%
Simplified92.1%
Applied egg-rr98.4%
Taylor expanded in x around 0 7.5%
Taylor expanded in x around inf 7.5%
Final simplification10.9%
(FPCore (x) :precision binary64 (/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))))))
double code(double x) {
return 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + cbrt((1.0 + x)))));
}
public static double code(double x) {
return 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
}
function code(x) return Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $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]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)\right)}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Taylor expanded in x around inf 47.8%
unpow1/349.9%
Simplified49.9%
fma-undefine49.9%
+-commutative49.9%
unpow249.9%
cbrt-prod95.9%
pow295.9%
Applied egg-rr95.9%
unpow295.9%
distribute-lft-out95.9%
Simplified95.9%
Final simplification95.9%
(FPCore (x) :precision binary64 (- (/ 1.5 x) (/ 2.25 (pow x 2.0))))
double code(double x) {
return (1.5 / x) - (2.25 / pow(x, 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.5d0 / x) - (2.25d0 / (x ** 2.0d0))
end function
public static double code(double x) {
return (1.5 / x) - (2.25 / Math.pow(x, 2.0));
}
def code(x): return (1.5 / x) - (2.25 / math.pow(x, 2.0))
function code(x) return Float64(Float64(1.5 / x) - Float64(2.25 / (x ^ 2.0))) end
function tmp = code(x) tmp = (1.5 / x) - (2.25 / (x ^ 2.0)); end
code[x_] := N[(N[(1.5 / x), $MachinePrecision] - N[(2.25 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.5}{x} - \frac{2.25}{{x}^{2}}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Applied egg-rr98.4%
Taylor expanded in x around 0 8.1%
Taylor expanded in x around inf 8.1%
associate-*r/8.1%
metadata-eval8.1%
associate-*r/8.1%
metadata-eval8.1%
Simplified8.1%
Final simplification8.1%
(FPCore (x) :precision binary64 (/ 1.0 (+ 1.0 (* x 0.6666666666666666))))
double code(double x) {
return 1.0 / (1.0 + (x * 0.6666666666666666));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (1.0d0 + (x * 0.6666666666666666d0))
end function
public static double code(double x) {
return 1.0 / (1.0 + (x * 0.6666666666666666));
}
def code(x): return 1.0 / (1.0 + (x * 0.6666666666666666))
function code(x) return Float64(1.0 / Float64(1.0 + Float64(x * 0.6666666666666666))) end
function tmp = code(x) tmp = 1.0 / (1.0 + (x * 0.6666666666666666)); end
code[x_] := N[(1.0 / N[(1.0 + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + x \cdot 0.6666666666666666}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Applied egg-rr98.4%
Taylor expanded in x around 0 8.1%
Final simplification8.1%
(FPCore (x) :precision binary64 (/ 1.5 x))
double code(double x) {
return 1.5 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.5d0 / x
end function
public static double code(double x) {
return 1.5 / x;
}
def code(x): return 1.5 / x
function code(x) return Float64(1.5 / x) end
function tmp = code(x) tmp = 1.5 / x; end
code[x_] := N[(1.5 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.5}{x}
\end{array}
Initial program 7.7%
flip3--8.0%
div-inv8.0%
rem-cube-cbrt7.3%
rem-cube-cbrt10.5%
+-commutative10.5%
distribute-rgt-out10.5%
+-commutative10.5%
fma-define10.5%
add-exp-log10.5%
Applied egg-rr10.4%
associate-*r/10.4%
*-rgt-identity10.4%
+-commutative10.4%
associate--l+93.2%
+-inverses93.2%
metadata-eval93.2%
+-commutative93.2%
exp-prod92.5%
Simplified92.5%
Applied egg-rr98.4%
Taylor expanded in x around 0 8.1%
Taylor expanded in x around inf 8.1%
Final simplification8.1%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 7.7%
Taylor expanded in x around inf 4.1%
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.7%
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 2024044
(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)))