
(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 12 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 (exp (* 0.6666666666666666 (log1p x)))))
(/
1.0
(fma
(cbrt x)
(+
(/ (+ 1.0 x) (+ t_0 (* 0.0 (cbrt (+ 1.0 x)))))
(/ x (+ (pow (cbrt x) 2.0) (* (cbrt x) 0.0))))
t_0))))
double code(double x) {
double t_0 = exp((0.6666666666666666 * log1p(x)));
return 1.0 / fma(cbrt(x), (((1.0 + x) / (t_0 + (0.0 * cbrt((1.0 + x))))) + (x / (pow(cbrt(x), 2.0) + (cbrt(x) * 0.0)))), t_0);
}
function code(x) t_0 = exp(Float64(0.6666666666666666 * log1p(x))) return Float64(1.0 / fma(cbrt(x), Float64(Float64(Float64(1.0 + x) / Float64(t_0 + Float64(0.0 * cbrt(Float64(1.0 + x))))) + Float64(x / Float64((cbrt(x) ^ 2.0) + Float64(cbrt(x) * 0.0)))), t_0)) end
code[x_] := Block[{t$95$0 = N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[(N[(1.0 + x), $MachinePrecision] / N[(t$95$0 + N[(0.0 * N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \frac{1 + x}{t\_0 + 0 \cdot \sqrt[3]{1 + x}} + \frac{x}{{\left(\sqrt[3]{x}\right)}^{2} + \sqrt[3]{x} \cdot 0}, t\_0\right)}
\end{array}
\end{array}
Initial program 6.8%
flip3--6.7%
rem-cube-cbrt5.9%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
pow1/38.3%
pow1/38.3%
pow-prod-up8.3%
Applied egg-rr8.3%
Taylor expanded in x around 0 93.0%
add093.0%
flip3-+93.0%
metadata-eval93.0%
add093.0%
rem-cube-cbrt93.0%
add-exp-log95.3%
pow1/396.0%
pow1/395.9%
pow-prod-up95.9%
log-pow98.9%
metadata-eval98.9%
+-commutative98.9%
log1p-define98.9%
metadata-eval98.9%
Applied egg-rr98.9%
add098.9%
flip3-+98.9%
metadata-eval98.9%
add098.9%
rem-cube-cbrt99.5%
pow299.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (* 0.6666666666666666 (log1p x)))))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (/ (+ 1.0 x) (+ t_0 (* 0.0 (cbrt (+ 1.0 x))))))
t_0))))
double code(double x) {
double t_0 = exp((0.6666666666666666 * log1p(x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + ((1.0 + x) / (t_0 + (0.0 * cbrt((1.0 + x)))))), t_0);
}
function code(x) t_0 = exp(Float64(0.6666666666666666 * log1p(x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(Float64(1.0 + x) / Float64(t_0 + Float64(0.0 * cbrt(Float64(1.0 + x)))))), t_0)) end
code[x_] := Block[{t$95$0 = N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] / N[(t$95$0 + N[(0.0 * N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \frac{1 + x}{t\_0 + 0 \cdot \sqrt[3]{1 + x}}, t\_0\right)}
\end{array}
\end{array}
Initial program 6.8%
flip3--6.7%
rem-cube-cbrt5.9%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
pow1/38.3%
pow1/38.3%
pow-prod-up8.3%
Applied egg-rr8.3%
Taylor expanded in x around 0 93.0%
add093.0%
flip3-+93.0%
metadata-eval93.0%
add093.0%
rem-cube-cbrt93.0%
add-exp-log95.3%
pow1/396.0%
pow1/395.9%
pow-prod-up95.9%
log-pow98.9%
metadata-eval98.9%
+-commutative98.9%
log1p-define98.9%
metadata-eval98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x 5e+153)
(/ 1.0 (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) t_0)))
(/ 1.0 (fma (cbrt x) t_0 (exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= 5e+153) {
tmp = 1.0 / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * t_0));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= 5e+153) tmp = Float64(1.0 / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * t_0))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5e+153], N[(1.0 / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_0, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if x < 5.00000000000000018e153Initial program 8.9%
expm1-log1p-u9.0%
Applied egg-rr9.0%
Applied egg-rr12.1%
Taylor expanded in x around 0 98.8%
if 5.00000000000000018e153 < x Initial program 4.8%
flip3--4.8%
rem-cube-cbrt2.9%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
pow1/34.8%
pow1/34.8%
pow-prod-up4.8%
Applied egg-rr4.8%
Taylor expanded in x around 0 92.2%
Final simplification95.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 6.8%
flip3--6.7%
rem-cube-cbrt5.9%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
pow1/38.3%
pow1/38.3%
pow-prod-up8.3%
Applied egg-rr8.3%
Taylor expanded in x around 0 93.0%
*-commutative93.0%
log1p-undefine93.0%
+-commutative93.0%
exp-to-pow92.9%
metadata-eval92.9%
pow-prod-up92.9%
pow1/394.3%
pow1/398.4%
pow298.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x 1.35e+154)
(/ 1.0 (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) t_0)))
(/ 1.0 (fma (cbrt x) t_0 (pow (+ 1.0 x) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * t_0));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(1.0 / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * t_0))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 8.8%
expm1-log1p-u8.9%
Applied egg-rr8.9%
Applied egg-rr12.0%
Taylor expanded in x around 0 98.8%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
rem-cube-cbrt2.9%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
pow1/34.8%
pow1/34.8%
pow-prod-up4.8%
Applied egg-rr4.8%
Taylor expanded in x around 0 92.2%
*-commutative92.2%
log1p-undefine92.2%
+-commutative92.2%
exp-to-pow91.6%
Applied egg-rr91.6%
Final simplification95.1%
(FPCore (x) :precision binary64 (/ 1.0 (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) (pow (+ 1.0 x) 0.6666666666666666))))
double code(double x) {
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((1.0 + x), 0.6666666666666666));
}
function code(x) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(1.0 + x) ^ 0.6666666666666666))) end
code[x_] := N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(1 + x\right)}^{0.6666666666666666}\right)}
\end{array}
Initial program 6.8%
flip3--6.7%
rem-cube-cbrt5.9%
rem-cube-cbrt8.3%
+-commutative8.3%
distribute-rgt-out8.3%
+-commutative8.3%
fma-define8.3%
add-exp-log8.3%
pow1/38.3%
pow1/38.3%
pow-prod-up8.3%
Applied egg-rr8.3%
Taylor expanded in x around 0 93.0%
*-commutative93.0%
log1p-undefine93.0%
+-commutative93.0%
exp-to-pow92.9%
Applied egg-rr92.9%
Final simplification92.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x 1.35e+16)
(/
(- (+ 1.0 x) x)
(+ (* (cbrt x) t_0) (pow (+ 1.0 x) 0.6666666666666666)))
(/ 1.0 (fma (cbrt x) t_0 (+ 1.0 (* x 0.6666666666666666)))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= 1.35e+16) {
tmp = ((1.0 + x) - x) / ((cbrt(x) * t_0) + pow((1.0 + x), 0.6666666666666666));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, (1.0 + (x * 0.6666666666666666)));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= 1.35e+16) tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(Float64(cbrt(x) * t_0) + (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, Float64(1.0 + Float64(x * 0.6666666666666666)))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.35e+16], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[(1.0 + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 1.35 \cdot 10^{+16}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{x} \cdot t\_0 + {\left(1 + x\right)}^{0.6666666666666666}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t\_0, 1 + x \cdot 0.6666666666666666\right)}\\
\end{array}
\end{array}
if x < 1.35e16Initial program 62.8%
expm1-log1p-u60.5%
Applied egg-rr60.5%
Applied egg-rr99.1%
pow1/397.9%
pow-pow97.9%
metadata-eval97.9%
Applied egg-rr97.9%
if 1.35e16 < x Initial program 4.2%
flip3--4.2%
rem-cube-cbrt3.3%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-define4.2%
add-exp-log4.2%
pow1/34.2%
pow1/34.2%
pow-prod-up4.2%
Applied egg-rr4.2%
Taylor expanded in x around 0 92.8%
Taylor expanded in x around 0 7.4%
Final simplification11.3%
(FPCore (x)
:precision binary64
(if (<= x 2.4e+15)
(- (pow (+ 1.0 x) 0.3333333333333333) (pow x 0.3333333333333333))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) (cbrt (+ 1.0 x)))
(+ 1.0 (* x 0.6666666666666666))))))
double code(double x) {
double tmp;
if (x <= 2.4e+15) {
tmp = pow((1.0 + x), 0.3333333333333333) - pow(x, 0.3333333333333333);
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), (1.0 + (x * 0.6666666666666666)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 2.4e+15) tmp = Float64((Float64(1.0 + x) ^ 0.3333333333333333) - (x ^ 0.3333333333333333)); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), Float64(1.0 + Float64(x * 0.6666666666666666)))); end return tmp end
code[x_] := If[LessEqual[x, 2.4e+15], N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] - N[Power[x, 0.3333333333333333], $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] + N[(1.0 + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{+15}:\\
\;\;\;\;{\left(1 + x\right)}^{0.3333333333333333} - {x}^{0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1 + x \cdot 0.6666666666666666\right)}\\
\end{array}
\end{array}
if x < 2.4e15Initial program 62.8%
pow1/360.0%
Applied egg-rr60.0%
pow1/364.1%
Applied egg-rr64.1%
if 2.4e15 < x Initial program 4.2%
flip3--4.2%
rem-cube-cbrt3.3%
rem-cube-cbrt4.2%
+-commutative4.2%
distribute-rgt-out4.2%
+-commutative4.2%
fma-define4.2%
add-exp-log4.2%
pow1/34.2%
pow1/34.2%
pow-prod-up4.2%
Applied egg-rr4.2%
Taylor expanded in x around 0 92.8%
Taylor expanded in x around 0 7.4%
Final simplification9.8%
(FPCore (x) :precision binary64 (+ (cbrt (+ 1.0 x)) (- 0.0 (pow x 0.3333333333333333))))
double code(double x) {
return cbrt((1.0 + x)) + (0.0 - pow(x, 0.3333333333333333));
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) + (0.0 - Math.pow(x, 0.3333333333333333));
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) + Float64(0.0 - (x ^ 0.3333333333333333))) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] + N[(0.0 - N[Power[x, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} + \left(0 - {x}^{0.3333333333333333}\right)
\end{array}
Initial program 6.8%
pow1/37.6%
Applied egg-rr7.6%
Final simplification7.6%
(FPCore (x) :precision binary64 (- (cbrt (+ 1.0 x)) (cbrt x)))
double code(double x) {
return cbrt((1.0 + x)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} - \sqrt[3]{x}
\end{array}
Initial program 6.8%
Final simplification6.8%
(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 6.8%
Taylor expanded in x around inf 4.2%
Final simplification4.2%
(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 6.8%
Taylor expanded in x around 0 6.1%
Final simplification6.1%
(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 2024046
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(/ 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)))