
(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)) 0.0)
(/ (+ 1.0 (- x x)) (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow t_0 2.0)))
(/
(- (+ 1.0 x) x)
(fma
(cbrt x)
(+ (cbrt x) t_0)
(exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(t_0, 2.0));
} else {
tmp = ((1.0 + x) - x) / fma(cbrt(x), (cbrt(x) + t_0), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (t_0 ^ 2.0))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / fma(cbrt(x), Float64(cbrt(x) + t_0), exp(Float64(0.6666666666666666 * log1p(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], 0.0], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {t_0}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.1%
pow1/33.2%
Applied egg-rr3.2%
Applied egg-rr4.1%
associate-*r/4.1%
*-rgt-identity4.1%
+-commutative4.1%
associate--l+98.3%
+-commutative98.3%
fma-def98.4%
+-commutative98.4%
+-commutative98.4%
Simplified98.4%
+-commutative98.4%
add-cube-cbrt98.1%
pow398.1%
Applied egg-rr98.1%
Taylor expanded in x around inf 52.7%
unpow1/398.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.5%
flip3--99.4%
rem-cube-cbrt99.3%
rem-cube-cbrt99.8%
+-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
fma-def99.8%
add-exp-log99.7%
pow1/399.8%
pow1/399.8%
pow-prod-up99.8%
log-pow99.8%
metadata-eval99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ (+ 1.0 (- x x)) (fma (cbrt x) (+ (cbrt x) (cbrt x)) (pow t_0 2.0)))
(/
1.0
(fma
(cbrt x)
(+ (cbrt x) t_0)
(exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + cbrt(x)), pow(t_0, 2.0));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + cbrt(x)), (t_0 ^ 2.0))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), exp(Float64(0.6666666666666666 * log1p(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], 0.0], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{x}, {t_0}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.1%
pow1/33.2%
Applied egg-rr3.2%
Applied egg-rr4.1%
associate-*r/4.1%
*-rgt-identity4.1%
+-commutative4.1%
associate--l+98.3%
+-commutative98.3%
fma-def98.4%
+-commutative98.4%
+-commutative98.4%
Simplified98.4%
+-commutative98.4%
add-cube-cbrt98.1%
pow398.1%
Applied egg-rr98.1%
Taylor expanded in x around inf 52.7%
unpow1/398.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.5%
flip3--99.4%
div-inv99.4%
rem-cube-cbrt99.3%
rem-cube-cbrt99.8%
+-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
fma-def99.8%
add-exp-log99.7%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
+-commutative99.8%
associate--l+99.8%
+-inverses99.8%
metadata-eval99.8%
+-commutative99.8%
exp-prod99.8%
Simplified99.8%
add-exp-log99.8%
log-pow99.8%
rem-log-exp99.8%
Applied egg-rr99.8%
Final simplification99.1%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ (+ 1.0 (- x x)) (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + t_0), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {t_0}^{2}\right)}
\end{array}
\end{array}
Initial program 51.4%
pow1/329.5%
Applied egg-rr29.5%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+99.0%
+-commutative99.0%
fma-def99.0%
+-commutative99.0%
+-commutative99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))
(exp (log (+ (pow (+ 1.0 x) 0.3333333333333333) (- (cbrt x))))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
} else {
tmp = exp(log((pow((1.0 + x), 0.3333333333333333) + -cbrt(x))));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); else tmp = exp(log(Float64((Float64(1.0 + x) ^ 0.3333333333333333) + Float64(-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], 0.0], 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[Exp[N[Log[N[(N[Power[N[(1.0 + x), $MachinePrecision], 0.3333333333333333], $MachinePrecision] + (-N[Power[x, 1/3], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left({\left(1 + x\right)}^{0.3333333333333333} + \left(-\sqrt[3]{x}\right)\right)}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0Initial program 4.1%
flip3--4.1%
div-inv4.1%
rem-cube-cbrt3.9%
rem-cube-cbrt4.1%
+-commutative4.1%
distribute-rgt-out4.1%
+-commutative4.1%
fma-def4.1%
add-exp-log4.1%
Applied egg-rr2.3%
associate-*r/2.3%
*-rgt-identity2.3%
+-commutative2.3%
associate--l+52.2%
+-inverses52.2%
metadata-eval52.2%
+-commutative52.2%
exp-prod51.4%
Simplified51.4%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.5%
add-exp-log99.5%
Applied egg-rr99.5%
pow1/399.5%
Applied egg-rr99.5%
Final simplification59.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (pow x 2.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 <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt(pow(x, 2.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 <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt((x ^ 2.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, -1.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $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 -1:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{{x}^{2}}\right)}\\
\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 < -1Initial program 4.1%
flip3--4.1%
div-inv4.1%
rem-cube-cbrt4.4%
rem-cube-cbrt4.1%
+-commutative4.1%
distribute-rgt-out4.1%
+-commutative4.1%
fma-def4.1%
add-exp-log4.1%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
+-commutative0.0%
associate--l+0.0%
+-inverses0.0%
metadata-eval0.0%
+-commutative0.0%
exp-prod0.0%
Simplified0.0%
Taylor expanded in x around inf 56.3%
unpow1/359.2%
Simplified59.2%
if -1 < x Initial program 65.0%
flip3--64.9%
div-inv64.9%
rem-cube-cbrt64.7%
rem-cube-cbrt65.2%
+-commutative65.2%
distribute-rgt-out65.2%
+-commutative65.2%
fma-def65.2%
add-exp-log65.2%
Applied egg-rr65.2%
associate-*r/65.2%
*-rgt-identity65.2%
+-commutative65.2%
associate--l+97.5%
+-inverses97.5%
metadata-eval97.5%
+-commutative97.5%
exp-prod97.0%
Simplified97.0%
add-exp-log97.1%
log-pow97.5%
rem-log-exp97.5%
Applied egg-rr97.5%
Final simplification89.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (pow x 2.0))))
(/
(+ 1.0 (- x x))
(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.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt(pow(x, 2.0)));
} else {
tmp = (1.0 + (x - x)) / 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.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt((x ^ 2.0)))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / 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.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{{x}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1Initial program 4.1%
flip3--4.1%
div-inv4.1%
rem-cube-cbrt4.4%
rem-cube-cbrt4.1%
+-commutative4.1%
distribute-rgt-out4.1%
+-commutative4.1%
fma-def4.1%
add-exp-log4.1%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
+-commutative0.0%
associate--l+0.0%
+-inverses0.0%
metadata-eval0.0%
+-commutative0.0%
exp-prod0.0%
Simplified0.0%
Taylor expanded in x around inf 56.3%
unpow1/359.2%
Simplified59.2%
if -1 < x Initial program 65.0%
pow1/337.9%
Applied egg-rr37.9%
Applied egg-rr65.2%
associate-*r/65.2%
*-rgt-identity65.2%
+-commutative65.2%
associate--l+99.3%
+-commutative99.3%
fma-def99.2%
+-commutative99.2%
+-commutative99.2%
Simplified99.2%
pow1/397.3%
+-commutative97.3%
metadata-eval97.3%
pow-pow97.2%
pow-pow97.2%
pow-sqr97.2%
unpow297.2%
pow-pow97.3%
metadata-eval97.3%
pow1/397.8%
associate-*l*97.8%
+-commutative97.8%
*-commutative97.8%
pow1/397.3%
pow-prod-up98.3%
metadata-eval98.3%
pow1/298.3%
+-commutative98.3%
add-sqr-sqrt70.7%
hypot-1-def70.7%
Applied egg-rr70.7%
*-commutative70.7%
hypot-udef70.7%
metadata-eval70.7%
add-sqr-sqrt98.3%
pow1/298.3%
metadata-eval98.3%
pow-prod-up97.3%
+-commutative97.3%
pow1/397.8%
associate-*r*97.8%
pow1/397.3%
pow-sqr97.3%
metadata-eval97.3%
+-commutative97.3%
+-commutative97.3%
+-commutative97.3%
pow-prod-up97.3%
+-commutative97.3%
metadata-eval97.3%
Applied egg-rr97.3%
Final simplification88.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 1.0))
(/
(+ 1.0 (- x x))
(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.0) {
tmp = 1.0 / fma(cbrt(x), t_0, 1.0);
} else {
tmp = (1.0 + (x - x)) / 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.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, 1.0)); else tmp = Float64(Float64(1.0 + Float64(x - x)) / 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.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < -1Initial program 4.1%
flip3--4.1%
div-inv4.1%
rem-cube-cbrt4.4%
rem-cube-cbrt4.1%
+-commutative4.1%
distribute-rgt-out4.1%
+-commutative4.1%
fma-def4.1%
add-exp-log4.1%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
+-commutative0.0%
associate--l+0.0%
+-inverses0.0%
metadata-eval0.0%
+-commutative0.0%
exp-prod0.0%
Simplified0.0%
Taylor expanded in x around 0 19.9%
if -1 < x Initial program 65.0%
pow1/337.9%
Applied egg-rr37.9%
Applied egg-rr65.2%
associate-*r/65.2%
*-rgt-identity65.2%
+-commutative65.2%
associate--l+99.3%
+-commutative99.3%
fma-def99.2%
+-commutative99.2%
+-commutative99.2%
Simplified99.2%
pow1/397.3%
+-commutative97.3%
metadata-eval97.3%
pow-pow97.2%
pow-pow97.2%
pow-sqr97.2%
unpow297.2%
pow-pow97.3%
metadata-eval97.3%
pow1/397.8%
associate-*l*97.8%
+-commutative97.8%
*-commutative97.8%
pow1/397.3%
pow-prod-up98.3%
metadata-eval98.3%
pow1/298.3%
+-commutative98.3%
add-sqr-sqrt70.7%
hypot-1-def70.7%
Applied egg-rr70.7%
*-commutative70.7%
hypot-udef70.7%
metadata-eval70.7%
add-sqr-sqrt98.3%
pow1/298.3%
metadata-eval98.3%
pow-prod-up97.3%
+-commutative97.3%
pow1/397.8%
associate-*r*97.8%
pow1/397.3%
pow-sqr97.3%
metadata-eval97.3%
+-commutative97.3%
+-commutative97.3%
+-commutative97.3%
pow-prod-up97.3%
+-commutative97.3%
metadata-eval97.3%
Applied egg-rr97.3%
Final simplification80.1%
(FPCore (x) :precision binary64 (/ (+ 1.0 (- x x)) (fma (cbrt x) (+ 1.0 (cbrt x)) (pow (cbrt (+ 1.0 x)) 2.0))))
double code(double x) {
return (1.0 + (x - x)) / fma(cbrt(x), (1.0 + cbrt(x)), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) return Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(1.0 + cbrt(x)), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, 1 + \sqrt[3]{x}, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
Initial program 51.4%
pow1/329.5%
Applied egg-rr29.5%
Applied egg-rr51.6%
associate-*r/51.6%
*-rgt-identity51.6%
+-commutative51.6%
associate--l+99.0%
+-commutative99.0%
fma-def99.0%
+-commutative99.0%
+-commutative99.0%
Simplified99.0%
+-commutative99.0%
add-cube-cbrt98.9%
pow398.9%
Applied egg-rr98.9%
Taylor expanded in x around 0 58.1%
Final simplification58.1%
(FPCore (x) :precision binary64 (exp (log (- (cbrt (+ 1.0 x)) (cbrt x)))))
double code(double x) {
return exp(log((cbrt((1.0 + x)) - cbrt(x))));
}
public static double code(double x) {
return Math.exp(Math.log((Math.cbrt((1.0 + x)) - Math.cbrt(x))));
}
function code(x) return exp(log(Float64(cbrt(Float64(1.0 + x)) - cbrt(x)))) end
code[x_] := N[Exp[N[Log[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\log \left(\sqrt[3]{1 + x} - \sqrt[3]{x}\right)}
\end{array}
Initial program 51.4%
add-exp-log51.4%
Applied egg-rr51.4%
Final simplification51.4%
(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 51.4%
Final simplification51.4%
(FPCore (x) :precision binary64 (+ 1.0 (- (* x 0.3333333333333333) (cbrt x))))
double code(double x) {
return 1.0 + ((x * 0.3333333333333333) - cbrt(x));
}
public static double code(double x) {
return 1.0 + ((x * 0.3333333333333333) - Math.cbrt(x));
}
function code(x) return Float64(1.0 + Float64(Float64(x * 0.3333333333333333) - cbrt(x))) end
code[x_] := N[(1.0 + N[(N[(x * 0.3333333333333333), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right)
\end{array}
Initial program 51.4%
add-cube-cbrt51.3%
pow351.3%
Applied egg-rr51.3%
Taylor expanded in x around 0 28.2%
associate--l+28.3%
*-commutative28.3%
metadata-eval28.3%
pow-base-128.3%
unpow1/349.8%
*-lft-identity49.8%
Simplified49.8%
Final simplification49.8%
(FPCore (x) :precision binary64 (- 1.0 (cbrt x)))
double code(double x) {
return 1.0 - cbrt(x);
}
public static double code(double x) {
return 1.0 - Math.cbrt(x);
}
function code(x) return Float64(1.0 - cbrt(x)) end
code[x_] := N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt[3]{x}
\end{array}
Initial program 51.4%
add-cube-cbrt51.3%
pow351.3%
Applied egg-rr51.3%
Taylor expanded in x around 0 27.1%
metadata-eval27.1%
pow-base-127.1%
unpow1/349.3%
*-lft-identity49.3%
Simplified49.3%
Final simplification49.3%
(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 51.4%
Taylor expanded in x around inf 3.6%
Final simplification3.6%
(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 51.4%
Taylor expanded in x around 0 47.9%
Final simplification47.9%
herbie shell --seed 2024011
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))