
(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))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0)))
(/ (- (+ 1.0 x) x) (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) t_1))))))
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)) <= 0.0) {
tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
} else {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * t_1));
}
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)) <= 0.0) tmp = Float64(1.0 / fma(cbrt(x), t_1, (cbrt(x) ^ 2.0))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * t_1))); 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], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / 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$1), $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 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t_1}\\
\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.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+50.9%
+-inverses50.9%
metadata-eval50.9%
+-commutative50.9%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
pow1/348.6%
pow-pow40.7%
metadata-eval40.7%
Applied egg-rr40.7%
Taylor expanded in x around inf 48.6%
expm1-log1p-u48.6%
expm1-udef5.3%
+-commutative5.3%
+-commutative5.3%
unpow1/35.3%
unpow25.3%
cbrt-prod5.3%
unpow25.3%
Applied egg-rr5.3%
expm1-def98.4%
expm1-log1p98.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
flip3--98.4%
rem-cube-cbrt98.1%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(/
1.0
(fma
(cbrt x)
(+ (* (cbrt (cbrt x)) (cbrt (pow (cbrt x) 2.0))) 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(cbrt(x)) * cbrt(pow(cbrt(x), 2.0))) + 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(Float64(cbrt(cbrt(x)) * cbrt((cbrt(x) ^ 2.0))) + 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[(N[Power[N[Power[x, 1/3], $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $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]{\sqrt[3]{x}} \cdot \sqrt[3]{{\left(\sqrt[3]{x}\right)}^{2}} + t_0, {t_0}^{2}\right)}
\end{array}
\end{array}
Initial program 56.4%
flip3--56.4%
div-inv56.4%
rem-cube-cbrt56.1%
rem-cube-cbrt57.2%
cbrt-unprod57.2%
pow257.2%
distribute-rgt-out57.2%
+-commutative57.2%
Applied egg-rr57.2%
associate-*r/57.2%
*-rgt-identity57.2%
+-commutative57.2%
associate--l+78.0%
+-inverses78.0%
metadata-eval78.0%
+-commutative78.0%
fma-def78.0%
+-commutative78.0%
+-commutative78.0%
Simplified78.0%
expm1-log1p-u77.2%
expm1-udef77.2%
pow1/377.0%
unpow277.0%
pow-prod-down72.5%
+-commutative72.5%
pow1/372.6%
+-commutative72.6%
pow1/397.2%
pow297.2%
+-commutative97.2%
Applied egg-rr97.2%
expm1-def97.2%
expm1-log1p99.2%
Simplified99.2%
pow1/350.0%
add-cube-cbrt50.0%
unpow-prod-down50.0%
pow250.0%
pow1/397.7%
Applied egg-rr97.7%
*-commutative97.7%
unpow1/399.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
(if (<= (- t_0 (cbrt x)) 0.0)
(/ 1.0 (* (cbrt x) (+ (cbrt x) t_1)))
(/ (- (+ 1.0 x) x) (+ (cbrt (pow (+ 1.0 x) 2.0)) (* (cbrt x) t_1))))))
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)) <= 0.0) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + t_1));
} else {
tmp = ((1.0 + x) - x) / (cbrt(pow((1.0 + x), 2.0)) + (cbrt(x) * t_1));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = Math.cbrt(x) + t_0;
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + t_1));
} else {
tmp = ((1.0 + x) - x) / (Math.cbrt(Math.pow((1.0 + x), 2.0)) + (Math.cbrt(x) * t_1));
}
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)) <= 0.0) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + t_1))); else tmp = Float64(Float64(Float64(1.0 + x) - x) / Float64(cbrt((Float64(1.0 + x) ^ 2.0)) + Float64(cbrt(x) * t_1))); 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], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / 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$1), $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 0:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t_1}\\
\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.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+50.9%
+-inverses50.9%
metadata-eval50.9%
+-commutative50.9%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
pow1/348.6%
pow-pow40.7%
metadata-eval40.7%
Applied egg-rr40.7%
Taylor expanded in x around inf 48.6%
expm1-log1p-u48.6%
expm1-udef5.3%
+-commutative5.3%
+-commutative5.3%
unpow1/35.3%
unpow25.3%
cbrt-prod5.3%
unpow25.3%
Applied egg-rr5.3%
expm1-def98.4%
expm1-log1p98.4%
fma-udef98.4%
unpow298.4%
distribute-lft-out98.4%
Simplified98.4%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
flip3--98.4%
rem-cube-cbrt98.1%
rem-cube-cbrt99.8%
cbrt-unprod99.8%
pow299.8%
distribute-rgt-out99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 4e-6)
(/ 1.0 (* (cbrt x) (+ (cbrt x) (+ (cbrt x) t_0))))
(- (cbrt (/ 1.0 (/ (- 1.0 x) (- 1.0 (* x x))))) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 4e-6) {
tmp = 1.0 / (cbrt(x) * (cbrt(x) + (cbrt(x) + t_0)));
} else {
tmp = cbrt((1.0 / ((1.0 - x) / (1.0 - (x * x))))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 4e-6) {
tmp = 1.0 / (Math.cbrt(x) * (Math.cbrt(x) + (Math.cbrt(x) + t_0)));
} else {
tmp = Math.cbrt((1.0 / ((1.0 - x) / (1.0 - (x * x))))) - Math.cbrt(x);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 - cbrt(x)) <= 4e-6) tmp = Float64(1.0 / Float64(cbrt(x) * Float64(cbrt(x) + Float64(cbrt(x) + t_0)))); else tmp = Float64(cbrt(Float64(1.0 / Float64(Float64(1.0 - x) / Float64(1.0 - Float64(x * 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], 4e-6], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 / N[(N[(1.0 - x), $MachinePrecision] / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $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 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \left(\sqrt[3]{x} + t_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{1 - x}{1 - x \cdot x}}} - \sqrt[3]{x}\\
\end{array}
\end{array}
if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 3.99999999999999982e-6Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt4.4%
rem-cube-cbrt5.8%
cbrt-unprod5.8%
pow25.8%
distribute-rgt-out5.8%
+-commutative5.8%
Applied egg-rr5.8%
associate-*r/5.8%
*-rgt-identity5.8%
+-commutative5.8%
associate--l+51.7%
+-inverses51.7%
metadata-eval51.7%
+-commutative51.7%
fma-def51.8%
+-commutative51.8%
+-commutative51.8%
Simplified51.8%
pow1/349.5%
pow-pow41.7%
metadata-eval41.7%
Applied egg-rr41.7%
Taylor expanded in x around inf 49.2%
expm1-log1p-u49.2%
expm1-udef6.1%
+-commutative6.1%
+-commutative6.1%
unpow1/36.1%
unpow26.1%
cbrt-prod6.1%
unpow26.1%
Applied egg-rr6.1%
expm1-def98.1%
expm1-log1p98.1%
fma-udef98.0%
unpow298.0%
distribute-lft-out98.1%
Simplified98.1%
if 3.99999999999999982e-6 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 99.1%
add-exp-log97.6%
pow1/397.6%
log-pow97.6%
+-commutative97.6%
log1p-udef97.6%
Applied egg-rr97.6%
*-commutative97.6%
exp-prod97.6%
unpow1/397.6%
Simplified97.6%
log1p-udef97.6%
add-exp-log99.1%
flip-+99.1%
clear-num99.1%
metadata-eval99.1%
Applied egg-rr99.1%
Final simplification98.6%
(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 (/ (- 1.0 x) (- 1.0 (* x 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 / ((1.0 - x) / (1.0 - (x * 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(cbrt(Float64(1.0 / Float64(Float64(1.0 - x) / Float64(1.0 - Float64(x * 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[Power[N[(1.0 / N[(N[(1.0 - x), $MachinePrecision] / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $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}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{1 - x}{1 - x \cdot 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.8%
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+50.9%
+-inverses50.9%
metadata-eval50.9%
+-commutative50.9%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
Taylor expanded in x around 0 19.9%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
add-exp-log96.6%
pow1/396.7%
log-pow96.6%
+-commutative96.6%
log1p-udef96.6%
Applied egg-rr96.6%
*-commutative96.6%
exp-prod96.7%
unpow1/396.6%
Simplified96.6%
log1p-udef96.6%
add-exp-log98.2%
flip-+98.2%
clear-num98.3%
metadata-eval98.3%
Applied egg-rr98.3%
Final simplification63.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 56.4%
flip3--56.4%
div-inv56.4%
rem-cube-cbrt56.1%
rem-cube-cbrt57.2%
cbrt-unprod57.2%
pow257.2%
distribute-rgt-out57.2%
+-commutative57.2%
Applied egg-rr57.2%
associate-*r/57.2%
*-rgt-identity57.2%
+-commutative57.2%
associate--l+78.0%
+-inverses78.0%
metadata-eval78.0%
+-commutative78.0%
fma-def78.0%
+-commutative78.0%
+-commutative78.0%
Simplified78.0%
expm1-log1p-u77.2%
expm1-udef77.2%
pow1/377.0%
unpow277.0%
pow-prod-down72.5%
+-commutative72.5%
pow1/372.6%
+-commutative72.6%
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 (if (<= (- (cbrt (+ 1.0 x)) (cbrt x)) 0.0) (cbrt (/ (/ 1.0 x) x)) (- (cbrt (/ 1.0 (/ (- 1.0 x) (- 1.0 (* x 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 / ((1.0 - x) / (1.0 - (x * x))))) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((Math.cbrt((1.0 + x)) - Math.cbrt(x)) <= 0.0) {
tmp = Math.cbrt(((1.0 / x) / x));
} else {
tmp = Math.cbrt((1.0 / ((1.0 - x) / (1.0 - (x * x))))) - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) <= 0.0) tmp = cbrt(Float64(Float64(1.0 / x) / x)); else tmp = Float64(cbrt(Float64(1.0 / Float64(Float64(1.0 - x) / Float64(1.0 - Float64(x * x))))) - cbrt(x)); end return tmp end
code[x_] := If[LessEqual[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[Power[N[(N[(1.0 / x), $MachinePrecision] / x), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(1.0 / N[(N[(1.0 - x), $MachinePrecision] / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{\frac{1}{x}}{x}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{1 - x}{1 - x \cdot 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.8%
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+50.9%
+-inverses50.9%
metadata-eval50.9%
+-commutative50.9%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
pow1/348.6%
pow-pow40.7%
metadata-eval40.7%
Applied egg-rr40.7%
Taylor expanded in x around inf 11.1%
unpow1/311.1%
unpow211.1%
associate-/r*11.6%
Simplified11.6%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
add-exp-log96.6%
pow1/396.7%
log-pow96.6%
+-commutative96.6%
log1p-udef96.6%
Applied egg-rr96.6%
*-commutative96.6%
exp-prod96.7%
unpow1/396.6%
Simplified96.6%
log1p-udef96.6%
add-exp-log98.2%
flip-+98.2%
clear-num98.3%
metadata-eval98.3%
Applied egg-rr98.3%
Final simplification59.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= (- t_0 (cbrt x)) 0.0)
(cbrt (/ (/ 1.0 x) x))
(- (+ (+ 1.0 t_0) -1.0) (cbrt x)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if ((t_0 - cbrt(x)) <= 0.0) {
tmp = cbrt(((1.0 / x) / x));
} else {
tmp = ((1.0 + t_0) + -1.0) - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double tmp;
if ((t_0 - Math.cbrt(x)) <= 0.0) {
tmp = Math.cbrt(((1.0 / x) / x));
} else {
tmp = ((1.0 + t_0) + -1.0) - Math.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 = cbrt(Float64(Float64(1.0 / x) / x)); else tmp = Float64(Float64(Float64(1.0 + t_0) + -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], 0.0], N[Power[N[(N[(1.0 / x), $MachinePrecision] / x), $MachinePrecision], 1/3], $MachinePrecision], N[(N[(N[(1.0 + t$95$0), $MachinePrecision] + -1.0), $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:\\
\;\;\;\;\sqrt[3]{\frac{\frac{1}{x}}{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + t_0\right) + -1\right) - \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.8%
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+50.9%
+-inverses50.9%
metadata-eval50.9%
+-commutative50.9%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
pow1/348.6%
pow-pow40.7%
metadata-eval40.7%
Applied egg-rr40.7%
Taylor expanded in x around inf 11.1%
unpow1/311.1%
unpow211.1%
associate-/r*11.6%
Simplified11.6%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
expm1-log1p-u96.6%
expm1-udef96.6%
log1p-udef96.6%
add-exp-log98.2%
Applied egg-rr98.2%
Final simplification59.7%
(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(Float64(1.0 / 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[(N[(1.0 / x), $MachinePrecision] / x), $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{\frac{1}{x}}{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.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+50.9%
+-inverses50.9%
metadata-eval50.9%
+-commutative50.9%
fma-def51.0%
+-commutative51.0%
+-commutative51.0%
Simplified51.0%
pow1/348.6%
pow-pow40.7%
metadata-eval40.7%
Applied egg-rr40.7%
Taylor expanded in x around inf 11.1%
unpow1/311.1%
unpow211.1%
associate-/r*11.6%
Simplified11.6%
if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) Initial program 98.2%
Final simplification59.7%
(FPCore (x) :precision binary64 (if (or (<= x -0.95) (not (<= x 2.7))) (cbrt (/ (/ 1.0 x) x)) (+ 1.0 (- (* x 0.3333333333333333) (cbrt x)))))
double code(double x) {
double tmp;
if ((x <= -0.95) || !(x <= 2.7)) {
tmp = cbrt(((1.0 / x) / x));
} else {
tmp = 1.0 + ((x * 0.3333333333333333) - cbrt(x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.95) || !(x <= 2.7)) {
tmp = Math.cbrt(((1.0 / x) / x));
} else {
tmp = 1.0 + ((x * 0.3333333333333333) - Math.cbrt(x));
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.95) || !(x <= 2.7)) tmp = cbrt(Float64(Float64(1.0 / x) / x)); else tmp = Float64(1.0 + Float64(Float64(x * 0.3333333333333333) - cbrt(x))); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.95], N[Not[LessEqual[x, 2.7]], $MachinePrecision]], N[Power[N[(N[(1.0 / x), $MachinePrecision] / x), $MachinePrecision], 1/3], $MachinePrecision], N[(1.0 + N[(N[(x * 0.3333333333333333), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.95 \lor \neg \left(x \leq 2.7\right):\\
\;\;\;\;\sqrt[3]{\frac{\frac{1}{x}}{x}}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right)\\
\end{array}
\end{array}
if x < -0.94999999999999996 or 2.7000000000000002 < x Initial program 7.0%
flip3--7.2%
div-inv7.2%
rem-cube-cbrt6.7%
rem-cube-cbrt8.9%
cbrt-unprod8.9%
pow28.9%
distribute-rgt-out8.9%
+-commutative8.9%
Applied egg-rr8.9%
associate-*r/8.9%
*-rgt-identity8.9%
+-commutative8.9%
associate--l+53.3%
+-inverses53.3%
metadata-eval53.3%
+-commutative53.3%
fma-def53.3%
+-commutative53.3%
+-commutative53.3%
Simplified53.3%
pow1/351.1%
pow-pow41.1%
metadata-eval41.1%
Applied egg-rr41.1%
Taylor expanded in x around inf 11.5%
unpow1/311.5%
unpow211.5%
associate-/r*11.9%
Simplified11.9%
if -0.94999999999999996 < x < 2.7000000000000002Initial program 99.9%
add-cube-cbrt99.9%
pow399.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 56.5%
associate--l+56.6%
*-commutative56.6%
metadata-eval56.6%
pow-base-156.6%
unpow1/398.7%
*-lft-identity98.7%
Simplified98.7%
Final simplification58.0%
(FPCore (x) :precision binary64 (if (or (<= x -0.43) (not (<= x 0.8))) (cbrt (/ 1.0 (* x x))) (- 1.0 (cbrt x))))
double code(double x) {
double tmp;
if ((x <= -0.43) || !(x <= 0.8)) {
tmp = cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.43) || !(x <= 0.8)) {
tmp = Math.cbrt((1.0 / (x * x)));
} else {
tmp = 1.0 - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.43) || !(x <= 0.8)) tmp = cbrt(Float64(1.0 / Float64(x * x))); else tmp = Float64(1.0 - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.43], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.43 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;\sqrt[3]{\frac{1}{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -0.429999999999999993 or 0.80000000000000004 < x Initial program 7.8%
flip3--8.0%
div-inv7.9%
rem-cube-cbrt7.4%
rem-cube-cbrt9.6%
cbrt-unprod9.6%
pow29.6%
distribute-rgt-out9.6%
+-commutative9.6%
Applied egg-rr9.6%
associate-*r/9.6%
*-rgt-identity9.6%
+-commutative9.6%
associate--l+53.6%
+-inverses53.6%
metadata-eval53.6%
+-commutative53.6%
fma-def53.7%
+-commutative53.7%
+-commutative53.7%
Simplified53.7%
pow1/351.5%
pow-pow41.6%
metadata-eval41.6%
Applied egg-rr41.6%
Taylor expanded in x around inf 11.5%
unpow1/311.5%
unpow211.5%
Simplified11.5%
if -0.429999999999999993 < x < 0.80000000000000004Initial program 99.9%
add-cube-cbrt99.9%
pow399.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 55.8%
metadata-eval55.8%
pow-base-155.8%
unpow1/397.8%
*-lft-identity97.8%
Simplified97.8%
Final simplification57.0%
(FPCore (x) :precision binary64 (if (or (<= x -0.43) (not (<= x 0.8))) (cbrt (/ (/ 1.0 x) x)) (- 1.0 (cbrt x))))
double code(double x) {
double tmp;
if ((x <= -0.43) || !(x <= 0.8)) {
tmp = cbrt(((1.0 / x) / x));
} else {
tmp = 1.0 - cbrt(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -0.43) || !(x <= 0.8)) {
tmp = Math.cbrt(((1.0 / x) / x));
} else {
tmp = 1.0 - Math.cbrt(x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.43) || !(x <= 0.8)) tmp = cbrt(Float64(Float64(1.0 / x) / x)); else tmp = Float64(1.0 - cbrt(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.43], N[Not[LessEqual[x, 0.8]], $MachinePrecision]], N[Power[N[(N[(1.0 / x), $MachinePrecision] / x), $MachinePrecision], 1/3], $MachinePrecision], N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.43 \lor \neg \left(x \leq 0.8\right):\\
\;\;\;\;\sqrt[3]{\frac{\frac{1}{x}}{x}}\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt[3]{x}\\
\end{array}
\end{array}
if x < -0.429999999999999993 or 0.80000000000000004 < x Initial program 7.8%
flip3--8.0%
div-inv7.9%
rem-cube-cbrt7.4%
rem-cube-cbrt9.6%
cbrt-unprod9.6%
pow29.6%
distribute-rgt-out9.6%
+-commutative9.6%
Applied egg-rr9.6%
associate-*r/9.6%
*-rgt-identity9.6%
+-commutative9.6%
associate--l+53.6%
+-inverses53.6%
metadata-eval53.6%
+-commutative53.6%
fma-def53.7%
+-commutative53.7%
+-commutative53.7%
Simplified53.7%
pow1/351.5%
pow-pow41.6%
metadata-eval41.6%
Applied egg-rr41.6%
Taylor expanded in x around inf 11.5%
unpow1/311.5%
unpow211.5%
associate-/r*11.9%
Simplified11.9%
if -0.429999999999999993 < x < 0.80000000000000004Initial program 99.9%
add-cube-cbrt99.9%
pow399.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 55.8%
metadata-eval55.8%
pow-base-155.8%
unpow1/397.8%
*-lft-identity97.8%
Simplified97.8%
Final simplification57.2%
(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 56.4%
add-cube-cbrt56.1%
pow356.0%
Applied egg-rr56.0%
Taylor expanded in x around 0 29.8%
metadata-eval29.8%
pow-base-129.8%
unpow1/353.4%
*-lft-identity53.4%
Simplified53.4%
Final simplification53.4%
(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 56.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 56.4%
Taylor expanded in x around 0 52.1%
Final simplification52.1%
herbie shell --seed 2023253
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))