
(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 (sqrt (+ 1.0 x))))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) (* t_0 t_0)) (pow (cbrt (+ 1.0 x)) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + (t_0 * t_0)), pow(cbrt((1.0 + x)), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + Float64(t_0 * t_0)), (cbrt(Float64(1.0 + x)) ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt{1 + x}}\\
\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0 \cdot t\_0, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 8.5%
flip3--8.7%
div-inv8.7%
rem-cube-cbrt8.4%
rem-cube-cbrt10.9%
+-commutative10.9%
distribute-rgt-out10.9%
+-commutative10.9%
fma-define10.8%
add-exp-log10.8%
Applied egg-rr10.8%
associate-*r/10.8%
*-rgt-identity10.8%
+-commutative10.8%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
metadata-eval93.1%
pow1/394.5%
metadata-eval94.5%
pow1/398.5%
Applied egg-rr98.5%
pow1/394.5%
+-commutative94.5%
add-sqr-sqrt94.5%
metadata-eval94.5%
unpow-prod-down94.5%
metadata-eval94.5%
metadata-eval94.5%
Applied egg-rr94.5%
unpow1/395.8%
+-commutative95.8%
unpow1/398.5%
+-commutative98.5%
Simplified98.5%
pow298.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (pow t_0 2.0) (* (cbrt x) (+ (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / (pow(t_0, 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{{t\_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}
\end{array}
\end{array}
Initial program 8.5%
flip3--8.7%
div-inv8.7%
rem-cube-cbrt8.4%
rem-cube-cbrt10.9%
+-commutative10.9%
distribute-rgt-out10.9%
+-commutative10.9%
fma-define10.8%
add-exp-log10.8%
Applied egg-rr10.8%
associate-*r/10.8%
*-rgt-identity10.8%
+-commutative10.8%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
metadata-eval93.1%
pow1/394.5%
metadata-eval94.5%
pow1/398.5%
cbrt-unprod51.0%
pow251.0%
Applied egg-rr51.0%
fma-undefine51.1%
+-commutative51.1%
unpow251.1%
cbrt-unprod98.5%
pow298.5%
+-commutative98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 25000000.0)
(* 2.0 (log (sqrt (exp (- t_0 (cbrt x))))))
(if (<= x 1.4e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 25000000.0) {
tmp = 2.0 * log(sqrt(exp((t_0 - cbrt(x)))));
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 25000000.0) tmp = Float64(2.0 * log(sqrt(exp(Float64(t_0 - cbrt(x)))))); elseif (x <= 1.4e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 25000000.0], N[(2.0 * N[Log[N[Sqrt[N[Exp[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;2 \cdot \log \left(\sqrt{e^{t\_0 - \sqrt[3]{x}}}\right)\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, 1\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
add-log-exp80.1%
add-sqr-sqrt80.4%
log-prod81.1%
Applied egg-rr81.1%
count-281.1%
+-commutative81.1%
Simplified81.1%
if 2.5e7 < x < 1.4e154Initial program 5.8%
Taylor expanded in x around inf 97.4%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.0%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod91.0%
Simplified91.0%
Taylor expanded in x around 0 20.0%
Final simplification57.4%
(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 8.5%
flip3--8.7%
div-inv8.7%
rem-cube-cbrt8.4%
rem-cube-cbrt10.9%
+-commutative10.9%
distribute-rgt-out10.9%
+-commutative10.9%
fma-define10.8%
add-exp-log10.8%
Applied egg-rr10.8%
associate-*r/10.8%
*-rgt-identity10.8%
+-commutative10.8%
associate--l+93.3%
+-inverses93.3%
metadata-eval93.3%
+-commutative93.3%
exp-prod92.5%
Simplified92.5%
pow-exp93.3%
*-commutative93.3%
log1p-undefine93.2%
+-commutative93.2%
exp-to-pow93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr93.1%
metadata-eval93.1%
pow1/394.5%
metadata-eval94.5%
pow1/398.5%
Applied egg-rr98.5%
pow298.5%
pow1/393.1%
pow-pow93.1%
metadata-eval93.1%
Applied egg-rr93.1%
Final simplification93.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 25000000.0)
(log (/ (exp t_0) (exp (cbrt x))))
(if (<= x 1.4e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 25000000.0) {
tmp = log((exp(t_0) / exp(cbrt(x))));
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 25000000.0) tmp = log(Float64(exp(t_0) / exp(cbrt(x)))); elseif (x <= 1.4e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 25000000.0], N[Log[N[(N[Exp[t$95$0], $MachinePrecision] / N[Exp[N[Power[x, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;\log \left(\frac{e^{t\_0}}{e^{\sqrt[3]{x}}}\right)\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, 1\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
sub-neg80.1%
+-commutative80.1%
add-sqr-sqrt79.2%
distribute-rgt-neg-in79.2%
fma-define79.7%
pow1/378.7%
sqrt-pow178.7%
metadata-eval78.7%
pow1/379.2%
sqrt-pow179.2%
metadata-eval79.2%
Applied egg-rr79.2%
metadata-eval79.2%
sqrt-pow179.2%
pow1/378.7%
expm1-log1p-u78.1%
add-sqr-sqrt0.0%
sqrt-unprod13.0%
sqr-neg13.0%
pow-prod-up13.0%
metadata-eval13.0%
pow1/313.0%
expm1-log1p-u13.0%
+-commutative13.0%
fma-define13.0%
add-sqr-sqrt13.0%
expm1-log1p-u13.0%
+-commutative13.0%
expm1-log1p-u13.0%
add-sqr-sqrt13.0%
Applied egg-rr80.6%
if 2.5e7 < x < 1.4e154Initial program 5.8%
Taylor expanded in x around inf 97.4%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.0%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod91.0%
Simplified91.0%
Taylor expanded in x around 0 20.0%
Final simplification57.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 25000000.0)
(pow (cbrt (- t_0 (cbrt x))) 3.0)
(if (<= x 1.4e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) 1.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 25000000.0) {
tmp = pow(cbrt((t_0 - cbrt(x))), 3.0);
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 1.0);
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 25000000.0) tmp = cbrt(Float64(t_0 - cbrt(x))) ^ 3.0; elseif (x <= 1.4e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 25000000.0], N[Power[N[Power[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;{\left(\sqrt[3]{t\_0 - \sqrt[3]{x}}\right)}^{3}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, 1\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
add-cube-cbrt80.3%
pow380.3%
Applied egg-rr80.3%
if 2.5e7 < x < 1.4e154Initial program 5.8%
Taylor expanded in x around inf 97.4%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.0%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod91.0%
Simplified91.0%
Taylor expanded in x around 0 20.0%
Final simplification57.3%
(FPCore (x)
:precision binary64
(if (<= x 25000000.0)
(pow (cbrt (- (cbrt (+ 1.0 x)) (cbrt x))) 3.0)
(if (<= x 1.4e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/ 1.0 (+ 1.0 (* (cbrt x) (+ 1.0 (cbrt x))))))))
double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = pow(cbrt((cbrt((1.0 + x)) - cbrt(x))), 3.0);
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (cbrt(x) * (1.0 + cbrt(x))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = Math.pow(Math.cbrt((Math.cbrt((1.0 + x)) - Math.cbrt(x))), 3.0);
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (1.0 + Math.cbrt(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 25000000.0) tmp = cbrt(Float64(cbrt(Float64(1.0 + x)) - cbrt(x))) ^ 3.0; elseif (x <= 1.4e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(1.0 + cbrt(x))))); end return tmp end
code[x_] := If[LessEqual[x, 25000000.0], N[Power[N[Power[N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;{\left(\sqrt[3]{\sqrt[3]{1 + x} - \sqrt[3]{x}}\right)}^{3}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(1 + \sqrt[3]{x}\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
add-cube-cbrt80.3%
pow380.3%
Applied egg-rr80.3%
if 2.5e7 < x < 1.4e154Initial program 5.8%
Taylor expanded in x around inf 97.4%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.0%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod91.0%
Simplified91.0%
Taylor expanded in x around 0 17.7%
Final simplification56.2%
(FPCore (x)
:precision binary64
(if (<= x 25000000.0)
(- (cbrt (+ 1.0 x)) (cbrt x))
(if (<= x 1.4e+154)
(* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))
(/ 1.0 (+ 1.0 (* (cbrt x) (+ 1.0 (cbrt x))))))))
double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (cbrt(x) * (1.0 + cbrt(x))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else if (x <= 1.4e+154) {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
} else {
tmp = 1.0 / (1.0 + (Math.cbrt(x) * (1.0 + Math.cbrt(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 25000000.0) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); elseif (x <= 1.4e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(1.0 + cbrt(x))))); end return tmp end
code[x_] := If[LessEqual[x, 25000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(1.0 + N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(1 + \sqrt[3]{x}\right)}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
if 2.5e7 < x < 1.4e154Initial program 5.8%
Taylor expanded in x around inf 97.4%
if 1.4e154 < x Initial program 4.7%
flip3--4.7%
div-inv4.7%
rem-cube-cbrt3.0%
rem-cube-cbrt4.7%
+-commutative4.7%
distribute-rgt-out4.7%
+-commutative4.7%
fma-define4.7%
add-exp-log4.7%
Applied egg-rr4.7%
associate-*r/4.7%
*-rgt-identity4.7%
+-commutative4.7%
associate--l+91.9%
+-inverses91.9%
metadata-eval91.9%
+-commutative91.9%
exp-prod91.0%
Simplified91.0%
Taylor expanded in x around 0 17.7%
Final simplification56.2%
(FPCore (x) :precision binary64 (if (<= x 25000000.0) (- (cbrt (+ 1.0 x)) (cbrt x)) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0))))))
double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 25000000.0) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 25000000.0) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); end return tmp end
code[x_] := If[LessEqual[x, 25000000.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 25000000:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\end{array}
\end{array}
if x < 2.5e7Initial program 80.1%
if 2.5e7 < x Initial program 5.2%
Taylor expanded in x around inf 48.2%
Final simplification49.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 8.5%
Final simplification8.5%
(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 8.5%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.5%
fabs-neg5.5%
unpow1/35.5%
metadata-eval5.5%
pow-sqr5.5%
fabs-sqr5.5%
pow-sqr5.5%
metadata-eval5.5%
unpow1/35.5%
Simplified5.5%
Final simplification5.5%
(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 8.5%
sub-neg8.5%
+-commutative8.5%
add-sqr-sqrt8.2%
distribute-rgt-neg-in8.2%
fma-define7.9%
pow1/39.6%
sqrt-pow19.6%
metadata-eval9.6%
pow1/39.5%
sqrt-pow19.5%
metadata-eval9.5%
Applied egg-rr9.5%
Taylor expanded in x around inf 4.1%
distribute-rgt1-in4.1%
metadata-eval4.1%
mul0-lft4.1%
metadata-eval4.1%
distribute-lft-out--4.1%
distribute-rgt-out--4.1%
+-inverses4.1%
metadata-eval4.1%
Simplified4.1%
Final simplification4.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 2024079
(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)))