
(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 (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 52.4%
flip3--52.4%
div-inv52.4%
rem-cube-cbrt52.3%
rem-cube-cbrt53.1%
cbrt-unprod53.1%
pow253.1%
distribute-rgt-out53.1%
+-commutative53.1%
Applied egg-rr53.1%
associate-*r/53.1%
*-rgt-identity53.1%
+-commutative53.1%
associate--l+76.6%
+-inverses76.6%
metadata-eval76.6%
+-commutative76.6%
fma-def76.6%
+-commutative76.6%
+-commutative76.6%
Simplified76.6%
expm1-log1p-u75.8%
expm1-udef75.8%
pow1/375.7%
unpow275.7%
pow-prod-down72.7%
+-commutative72.7%
pow1/372.8%
+-commutative72.8%
pow1/397.2%
pow297.2%
+-commutative97.2%
Applied egg-rr97.2%
expm1-def97.2%
expm1-log1p99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 5e-10)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (cbrt (* x x))))
(- (/ (cbrt (- 1.0 (* x x))) (cbrt (- 1.0 x))) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 5e-10) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), cbrt((x * x)));
} else {
tmp = (cbrt((1.0 - (x * x))) / cbrt((1.0 - x))) - cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 5e-10) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), cbrt(Float64(x * x)))); else tmp = Float64(Float64(cbrt(Float64(1.0 - Float64(x * x))) / cbrt(Float64(1.0 - x))) - 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-10], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(1.0 - x), $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^{-10}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \sqrt[3]{x \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 - x \cdot x}}{\sqrt[3]{1 - x}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 5.00000000000000031e-10Initial program 4.5%
flip3--4.5%
div-inv4.5%
rem-cube-cbrt4.3%
rem-cube-cbrt5.6%
cbrt-unprod5.7%
pow25.7%
distribute-rgt-out5.7%
+-commutative5.7%
Applied egg-rr5.7%
associate-*r/5.7%
*-rgt-identity5.7%
+-commutative5.7%
associate--l+53.0%
+-inverses53.0%
metadata-eval53.0%
+-commutative53.0%
fma-def53.0%
+-commutative53.0%
+-commutative53.0%
Simplified53.0%
pow1/350.6%
pow-pow46.2%
metadata-eval46.2%
Applied egg-rr46.2%
Taylor expanded in x around inf 50.6%
unpow1/352.9%
unpow252.9%
Simplified52.9%
if 5.00000000000000031e-10 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.6%
add-exp-log98.2%
pow1/398.2%
log-pow98.2%
+-commutative98.2%
log1p-udef98.2%
Applied egg-rr98.2%
exp-prod98.2%
Simplified98.2%
pow-exp98.2%
log1p-udef98.2%
log-pow98.2%
pow1/398.2%
add-exp-log99.6%
flip-+99.6%
cbrt-div99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification76.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(exp (- (log (fma (cbrt x) t_0 1.0))))
(if (<= x 1.35e+154)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (pow (+ 1.0 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.35e+154) {
tmp = exp(-log(fma(cbrt(x), t_0, 1.0)));
} else if (x <= 1.35e+154) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt(pow((1.0 + 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.35e+154) tmp = exp(Float64(-log(fma(cbrt(x), t_0, 1.0)))); elseif (x <= 1.35e+154) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt((Float64(1.0 + 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.35e+154], N[Exp[(-N[Log[N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[x, 1.35e+154], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 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.35 \cdot 10^{+154}:\\
\;\;\;\;e^{-\log \left(\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)\right)}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{{\left(1 + x\right)}^{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 < -1.35000000000000003e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.5%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
add-exp-log4.7%
log-rec4.7%
+-commutative4.7%
pow1/34.7%
unpow24.7%
pow-prod-down0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/390.8%
pow290.8%
+-commutative90.8%
Applied egg-rr90.8%
Taylor expanded in x around 0 19.9%
if -1.35000000000000003e154 < x < 1.35000000000000003e154Initial program 67.7%
flip3--67.6%
div-inv67.6%
rem-cube-cbrt68.0%
rem-cube-cbrt68.6%
cbrt-unprod68.5%
pow268.5%
distribute-rgt-out68.6%
+-commutative68.6%
Applied egg-rr68.6%
associate-*r/68.6%
*-rgt-identity68.6%
+-commutative68.6%
associate--l+99.5%
+-inverses99.5%
metadata-eval99.5%
+-commutative99.5%
fma-def99.5%
+-commutative99.5%
+-commutative99.5%
Simplified99.5%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt3.0%
rem-cube-cbrt4.8%
cbrt-unprod4.8%
pow24.8%
distribute-rgt-out4.8%
+-commutative4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+4.8%
+-inverses4.8%
metadata-eval4.8%
+-commutative4.8%
fma-def4.8%
+-commutative4.8%
+-commutative4.8%
Simplified4.8%
add-exp-log4.8%
pow1/34.8%
log-pow4.8%
log-pow92.2%
log1p-udef92.2%
Applied egg-rr92.2%
associate-*r*92.2%
metadata-eval92.2%
Simplified92.2%
Final simplification88.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(exp (- (log (fma (cbrt x) t_0 1.0))))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (* x x))))
(/ 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.35e+154) {
tmp = exp(-log(fma(cbrt(x), t_0, 1.0)));
} else if (x <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt((x * x)));
} 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.35e+154) tmp = exp(Float64(-log(fma(cbrt(x), t_0, 1.0)))); elseif (x <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt(Float64(x * x)))); 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.35e+154], N[Exp[(-N[Log[N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[x, -1.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(x * x), $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.35 \cdot 10^{+154}:\\
\;\;\;\;e^{-\log \left(\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)\right)}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{x \cdot x}\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 < -1.35000000000000003e154Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.5%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
add-exp-log4.7%
log-rec4.7%
+-commutative4.7%
pow1/34.7%
unpow24.7%
pow-prod-down0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/390.8%
pow290.8%
+-commutative90.8%
Applied egg-rr90.8%
Taylor expanded in x around 0 19.9%
if -1.35000000000000003e154 < x < -1Initial program 9.5%
flip3--9.5%
div-inv9.5%
rem-cube-cbrt10.9%
rem-cube-cbrt12.0%
cbrt-unprod12.0%
pow212.0%
distribute-rgt-out12.1%
+-commutative12.1%
Applied egg-rr12.1%
associate-*r/12.1%
*-rgt-identity12.1%
+-commutative12.1%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
fma-def99.1%
+-commutative99.1%
+-commutative99.1%
Simplified99.1%
pow1/394.6%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 90.3%
unpow1/394.7%
unpow294.7%
Simplified94.7%
if -1 < x Initial program 68.1%
flip3--68.1%
div-inv68.1%
rem-cube-cbrt67.9%
rem-cube-cbrt68.6%
cbrt-unprod68.6%
pow268.6%
distribute-rgt-out68.6%
+-commutative68.6%
Applied egg-rr68.6%
associate-*r/68.6%
*-rgt-identity68.6%
+-commutative68.6%
associate--l+84.7%
+-inverses84.7%
metadata-eval84.7%
+-commutative84.7%
fma-def84.6%
+-commutative84.6%
+-commutative84.6%
Simplified84.6%
add-exp-log84.2%
pow1/384.1%
log-pow84.0%
log-pow97.8%
log1p-udef97.8%
Applied egg-rr97.8%
associate-*r*97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification87.7%
(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))
(- (/ (cbrt (- 1.0 (* x x))) (cbrt (- 1.0 x))) (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 = (cbrt((1.0 - (x * x))) / cbrt((1.0 - x))) - 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 = Float64(Float64(cbrt(Float64(1.0 - Float64(x * x))) / cbrt(Float64(1.0 - x))) - 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[(N[(N[Power[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(1.0 - x), $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 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 - x \cdot x}}{\sqrt[3]{1 - x}} - \sqrt[3]{x}\\
\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.9%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+52.2%
+-inverses52.2%
metadata-eval52.2%
+-commutative52.2%
fma-def52.2%
+-commutative52.2%
+-commutative52.2%
Simplified52.2%
Taylor expanded in x around 0 20.0%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.5%
add-exp-log96.8%
pow1/396.8%
log-pow96.8%
+-commutative96.8%
log1p-udef96.8%
Applied egg-rr96.8%
exp-prod96.9%
Simplified96.9%
pow-exp96.8%
log1p-udef96.8%
log-pow96.8%
pow1/396.8%
add-exp-log98.5%
flip-+98.5%
cbrt-div98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification60.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(exp (- (log (fma (cbrt x) t_0 1.0))))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (* x x))))
(/ 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 = exp(-log(fma(cbrt(x), t_0, 1.0)));
} else if (x <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt((x * x)));
} 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 = exp(Float64(-log(fma(cbrt(x), t_0, 1.0)))); elseif (x <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt(Float64(x * x)))); 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[Exp[(-N[Log[N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[x, -1.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(x * x), $MachinePrecision], 1/3], $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}:\\
\;\;\;\;e^{-\log \left(\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)\right)}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{x \cdot x}\right)}\\
\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 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.5%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
add-exp-log4.7%
log-rec4.7%
+-commutative4.7%
pow1/34.7%
unpow24.7%
pow-prod-down0.0%
+-commutative0.0%
pow1/30.0%
+-commutative0.0%
pow1/390.8%
pow290.8%
+-commutative90.8%
Applied egg-rr90.8%
Taylor expanded in x around 0 19.9%
if -1.35000000000000003e154 < x < -1Initial program 9.5%
flip3--9.5%
div-inv9.5%
rem-cube-cbrt10.9%
rem-cube-cbrt12.0%
cbrt-unprod12.0%
pow212.0%
distribute-rgt-out12.1%
+-commutative12.1%
Applied egg-rr12.1%
associate-*r/12.1%
*-rgt-identity12.1%
+-commutative12.1%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
fma-def99.1%
+-commutative99.1%
+-commutative99.1%
Simplified99.1%
pow1/394.6%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 90.3%
unpow1/394.7%
unpow294.7%
Simplified94.7%
if -1 < x Initial program 68.1%
flip3--68.1%
div-inv68.1%
rem-cube-cbrt67.9%
rem-cube-cbrt68.6%
cbrt-unprod68.6%
pow268.6%
distribute-rgt-out68.6%
+-commutative68.6%
Applied egg-rr68.6%
associate-*r/68.6%
*-rgt-identity68.6%
+-commutative68.6%
associate--l+84.7%
+-inverses84.7%
metadata-eval84.7%
+-commutative84.7%
fma-def84.6%
+-commutative84.6%
+-commutative84.6%
Simplified84.6%
pow1/383.9%
pow-pow97.6%
metadata-eval97.6%
Applied egg-rr97.6%
Final simplification87.5%
(FPCore (x) :precision binary64 (if (<= (- (cbrt (+ 1.0 x)) (cbrt x)) 0.0) (cbrt (/ 1.0 (* x x))) (- (/ (cbrt (- 1.0 (* x x))) (cbrt (- 1.0 x))) (cbrt x))))
double code(double x) {
double tmp;
if ((cbrt((1.0 + x)) - cbrt(x)) <= 0.0) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = (cbrt((1.0 - (x * x))) / cbrt((1.0 - x))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((Math.cbrt((1.0 + x)) - Math.cbrt(x)) <= 0.0) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = (Math.cbrt((1.0 - (x * x))) / Math.cbrt((1.0 - x))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) <= 0.0) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = Float64(Float64(cbrt(Float64(1.0 - Float64(x * x))) / cbrt(Float64(1.0 - 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], 0.0], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[(N[Power[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(1.0 - x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{1 - x \cdot x}}{\sqrt[3]{1 - x}} - \sqrt[3]{x}\\
\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.9%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+52.2%
+-inverses52.2%
metadata-eval52.2%
+-commutative52.2%
fma-def52.2%
+-commutative52.2%
+-commutative52.2%
Simplified52.2%
pow1/349.9%
pow-pow46.2%
metadata-eval46.2%
Applied egg-rr46.2%
Taylor expanded in x around inf 11.3%
unpow1/311.3%
unpow211.3%
Simplified11.3%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.5%
add-exp-log96.8%
pow1/396.8%
log-pow96.8%
+-commutative96.8%
log1p-udef96.8%
Applied egg-rr96.8%
exp-prod96.9%
Simplified96.9%
pow-exp96.8%
log1p-udef96.8%
log-pow96.8%
pow1/396.8%
add-exp-log98.5%
flip-+98.5%
cbrt-div98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification56.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.35e+154)
(/ 1.0 (fma (cbrt x) t_0 1.0))
(if (<= x -1.0)
(/ 1.0 (fma (cbrt x) t_0 (cbrt (* x x))))
(/ 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 / fma(cbrt(x), t_0, 1.0);
} else if (x <= -1.0) {
tmp = 1.0 / fma(cbrt(x), t_0, cbrt((x * x)));
} 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 / fma(cbrt(x), t_0, 1.0)); elseif (x <= -1.0) tmp = Float64(1.0 / fma(cbrt(x), t_0, cbrt(Float64(x * x)))); 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[x, 1/3], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(x * x), $MachinePrecision], 1/3], $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}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{x \cdot x}\right)}\\
\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 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.5%
rem-cube-cbrt4.7%
cbrt-unprod4.7%
pow24.7%
distribute-rgt-out4.7%
+-commutative4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+4.7%
+-inverses4.7%
metadata-eval4.7%
+-commutative4.7%
fma-def4.7%
+-commutative4.7%
+-commutative4.7%
Simplified4.7%
Taylor expanded in x around 0 19.9%
if -1.35000000000000003e154 < x < -1Initial program 9.5%
flip3--9.5%
div-inv9.5%
rem-cube-cbrt10.9%
rem-cube-cbrt12.0%
cbrt-unprod12.0%
pow212.0%
distribute-rgt-out12.1%
+-commutative12.1%
Applied egg-rr12.1%
associate-*r/12.1%
*-rgt-identity12.1%
+-commutative12.1%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
fma-def99.1%
+-commutative99.1%
+-commutative99.1%
Simplified99.1%
pow1/394.6%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 90.3%
unpow1/394.7%
unpow294.7%
Simplified94.7%
if -1 < x Initial program 68.1%
flip3--68.1%
div-inv68.1%
rem-cube-cbrt67.9%
rem-cube-cbrt68.6%
cbrt-unprod68.6%
pow268.6%
distribute-rgt-out68.6%
+-commutative68.6%
Applied egg-rr68.6%
associate-*r/68.6%
*-rgt-identity68.6%
+-commutative68.6%
associate--l+84.7%
+-inverses84.7%
metadata-eval84.7%
+-commutative84.7%
fma-def84.6%
+-commutative84.6%
+-commutative84.6%
Simplified84.6%
pow1/383.9%
pow-pow97.6%
metadata-eval97.6%
Applied egg-rr97.6%
Final simplification87.5%
(FPCore (x) :precision binary64 (let* ((t_0 (- (cbrt (+ 1.0 x)) (cbrt x)))) (if (<= t_0 0.0) (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 <= 0.0) {
tmp = 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 <= 0.0) {
tmp = 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 <= 0.0) tmp = 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, 0.0], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $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:\\
\;\;\;\;\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)) < 0.0Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.9%
rem-cube-cbrt4.2%
cbrt-unprod4.2%
pow24.2%
distribute-rgt-out4.2%
+-commutative4.2%
Applied egg-rr4.2%
associate-*r/4.2%
*-rgt-identity4.2%
+-commutative4.2%
associate--l+52.2%
+-inverses52.2%
metadata-eval52.2%
+-commutative52.2%
fma-def52.2%
+-commutative52.2%
+-commutative52.2%
Simplified52.2%
pow1/349.9%
pow-pow46.2%
metadata-eval46.2%
Applied egg-rr46.2%
Taylor expanded in x around inf 11.3%
unpow1/311.3%
unpow211.3%
Simplified11.3%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.5%
Final simplification55.9%
(FPCore (x) :precision binary64 (if (<= x -0.43) (cbrt (/ 1.0 (* x x))) (/ -1.0 (+ -1.0 (* x -0.6666666666666666)))))
double code(double x) {
double tmp;
if (x <= -0.43) {
tmp = 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 <= -0.43) {
tmp = 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 <= -0.43) tmp = 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[LessEqual[x, -0.43], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(-1.0 / N[(-1.0 + N[(x * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.43:\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{-1 + x \cdot -0.6666666666666666}\\
\end{array}
\end{array}
if x < -0.429999999999999993Initial program 7.2%
flip3--7.2%
div-inv7.2%
rem-cube-cbrt7.3%
rem-cube-cbrt8.5%
cbrt-unprod8.5%
pow28.5%
distribute-rgt-out8.5%
+-commutative8.5%
Applied egg-rr8.5%
associate-*r/8.5%
*-rgt-identity8.5%
+-commutative8.5%
associate--l+53.3%
+-inverses53.3%
metadata-eval53.3%
+-commutative53.3%
fma-def53.3%
+-commutative53.3%
+-commutative53.3%
Simplified53.3%
pow1/351.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 11.4%
unpow1/311.4%
unpow211.4%
Simplified11.4%
if -0.429999999999999993 < x Initial program 68.1%
flip3--68.1%
div-inv68.1%
rem-cube-cbrt67.9%
rem-cube-cbrt68.6%
cbrt-unprod68.6%
pow268.6%
distribute-rgt-out68.6%
+-commutative68.6%
Applied egg-rr68.6%
associate-*r/68.6%
*-rgt-identity68.6%
+-commutative68.6%
associate--l+84.7%
+-inverses84.7%
metadata-eval84.7%
+-commutative84.7%
fma-def84.6%
+-commutative84.6%
+-commutative84.6%
Simplified84.6%
Taylor expanded in x around 0 61.7%
*-commutative61.7%
Simplified61.7%
+-commutative61.7%
flip-+61.7%
*-commutative61.7%
*-commutative61.7%
swap-sqr61.7%
metadata-eval61.7%
metadata-eval61.7%
Applied egg-rr61.7%
Taylor expanded in x around 0 64.2%
Final simplification50.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 52.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 52.4%
Taylor expanded in x around 0 48.8%
Final simplification48.8%
herbie shell --seed 2023274
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))