
(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 11 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) (cbrt (+ 1.0 x))) (pow (* t_0 t_0) 2.0)))))
double code(double x) {
double t_0 = cbrt(sqrt((1.0 + x)));
return 1.0 / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), pow((t_0 * t_0), 2.0));
}
function code(x) t_0 = cbrt(sqrt(Float64(1.0 + x))) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), (Float64(t_0 * t_0) ^ 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[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$0 * t$95$0), $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} + \sqrt[3]{1 + x}, {\left(t\_0 \cdot t\_0\right)}^{2}\right)}
\end{array}
\end{array}
Initial program 7.1%
flip3--7.2%
div-inv7.2%
rem-cube-cbrt6.4%
rem-cube-cbrt9.0%
+-commutative9.0%
distribute-rgt-out9.0%
+-commutative9.0%
fma-define9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate-*r/9.0%
*-rgt-identity9.0%
+-commutative9.0%
associate--l+93.1%
+-commutative93.1%
+-commutative93.1%
Simplified93.1%
*-commutative93.1%
log1p-undefine93.1%
exp-to-pow93.0%
metadata-eval93.0%
pow-prod-up93.0%
+-commutative93.0%
pow1/394.5%
+-commutative94.5%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
pow1/393.0%
add-sqr-sqrt93.0%
unpow-prod-down93.0%
add-sqr-sqrt93.0%
hypot-1-def93.0%
add-sqr-sqrt93.0%
hypot-1-def93.0%
Applied egg-rr93.0%
unpow1/394.5%
hypot-undefine94.5%
metadata-eval94.5%
rem-square-sqrt94.5%
unpow1/398.6%
hypot-undefine98.6%
metadata-eval98.6%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 98.6%
(FPCore (x)
:precision binary64
(if (<= x 1.35e+154)
(/
1.0
(+ (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))) (cbrt (pow (+ 1.0 x) 2.0))))
(/
(+ 1.0 (- x x))
(fma (cbrt x) (* (cbrt x) 2.0) (exp (* 0.6666666666666666 (log1p x)))))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 1.0 / ((cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))) + cbrt(pow((1.0 + x), 2.0)));
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) * 2.0), exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(1.0 / Float64(Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))) + cbrt((Float64(1.0 + x) ^ 2.0)))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) * 2.0), exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(1.0 / N[(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]), $MachinePrecision] + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] * 2.0), $MachinePrecision] + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right) + \sqrt[3]{{\left(1 + x\right)}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.2%
add-exp-log9.9%
+-commutative9.9%
log1p-define9.9%
Applied egg-rr9.9%
log1p-undefine9.9%
add-exp-log9.2%
+-commutative9.2%
flip3--9.6%
pow310.1%
add-cube-cbrt9.8%
+-commutative9.8%
rem-cube-cbrt13.0%
associate-+r-98.5%
+-inverses98.5%
metadata-eval98.5%
Applied egg-rr93.7%
pow-exp94.4%
*-commutative94.4%
log1p-undefine94.4%
exp-to-pow94.5%
metadata-eval94.5%
pow-prod-up94.5%
pow1/395.8%
pow1/398.5%
cbrt-unprod98.7%
pow298.7%
Applied egg-rr98.7%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt2.8%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
Taylor expanded in x around inf 91.7%
*-commutative91.7%
Simplified91.7%
Final simplification95.3%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (* t_0 t_0) (* (cbrt x) (+ (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / ((t_0 * t_0) + (cbrt(x) * (cbrt(x) + t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / ((t_0 * t_0) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64(Float64(t_0 * t_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[(t$95$0 * t$95$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 \cdot t\_0 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}
\end{array}
\end{array}
Initial program 7.1%
add-exp-log6.5%
+-commutative6.5%
log1p-define6.5%
Applied egg-rr6.5%
log1p-undefine6.5%
add-exp-log7.1%
+-commutative7.1%
flip3--7.2%
pow37.3%
add-cube-cbrt6.4%
+-commutative6.4%
rem-cube-cbrt9.0%
associate-+r-98.4%
+-inverses98.4%
metadata-eval98.4%
Applied egg-rr92.2%
pow-exp93.1%
*-commutative93.1%
log1p-undefine93.1%
exp-to-pow93.0%
metadata-eval93.0%
pow-prod-up93.0%
pow1/394.5%
pow1/398.4%
Applied egg-rr98.4%
(FPCore (x)
:precision binary64
(if (<= x 1.35e+154)
(/
(fma
0.3333333333333333
(pow (cbrt x) 4.0)
(* (cbrt x) -0.1111111111111111))
(pow x 2.0))
(/ (+ 1.0 (- x x)) (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = fma(0.3333333333333333, pow(cbrt(x), 4.0), (cbrt(x) * -0.1111111111111111)) / pow(x, 2.0);
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(fma(0.3333333333333333, (cbrt(x) ^ 4.0), Float64(cbrt(x) * -0.1111111111111111)) / (x ^ 2.0)); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], 4.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision]), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 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[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.3333333333333333, {\left(\sqrt[3]{x}\right)}^{4}, \sqrt[3]{x} \cdot -0.1111111111111111\right)}{{x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.2%
add-exp-log9.9%
+-commutative9.9%
log1p-define9.9%
Applied egg-rr9.9%
Taylor expanded in x around inf 50.3%
+-commutative50.3%
fma-define50.3%
*-commutative50.3%
Simplified50.3%
pow1/347.0%
metadata-eval47.0%
pow-prod-up47.0%
unpow-prod-down89.2%
pow1/390.7%
unpow290.7%
cbrt-prod90.7%
pow290.7%
pow1/396.8%
unpow296.8%
cbrt-prod96.1%
pow296.1%
Applied egg-rr96.1%
pow-sqr96.2%
metadata-eval96.2%
Simplified96.2%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt2.8%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-commutative91.7%
log1p-undefine91.7%
exp-to-pow91.5%
metadata-eval91.5%
pow-prod-up91.5%
+-commutative91.5%
pow1/393.1%
+-commutative93.1%
pow1/398.3%
pow298.3%
+-commutative98.3%
Applied egg-rr98.3%
pow1/391.5%
add-sqr-sqrt91.5%
unpow-prod-down91.5%
add-sqr-sqrt91.5%
hypot-1-def91.5%
add-sqr-sqrt91.5%
hypot-1-def91.5%
Applied egg-rr91.5%
unpow1/393.0%
hypot-undefine93.0%
metadata-eval93.0%
rem-square-sqrt93.0%
unpow1/398.6%
hypot-undefine98.6%
metadata-eval98.6%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 19.9%
(FPCore (x) :precision binary64 (/ 1.0 (+ (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))) (exp (* 0.6666666666666666 (log1p x))))))
double code(double x) {
return 1.0 / ((cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))) + exp((0.6666666666666666 * log1p(x))));
}
public static double code(double x) {
return 1.0 / ((Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)))) + Math.exp((0.6666666666666666 * Math.log1p(x))));
}
function code(x) return Float64(1.0 / Float64(Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))) + exp(Float64(0.6666666666666666 * log1p(x))))) end
code[x_] := N[(1.0 / N[(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]), $MachinePrecision] + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right) + e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}}
\end{array}
Initial program 7.1%
add-exp-log6.5%
+-commutative6.5%
log1p-define6.5%
Applied egg-rr6.5%
log1p-undefine6.5%
add-exp-log7.1%
+-commutative7.1%
flip3--7.2%
pow37.3%
add-cube-cbrt6.4%
+-commutative6.4%
rem-cube-cbrt9.0%
associate-+r-98.4%
+-inverses98.4%
metadata-eval98.4%
Applied egg-rr92.2%
pow-exp93.1%
*-commutative93.1%
Applied egg-rr93.1%
Final simplification93.1%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (/ (+ 1.0 (- x x)) (fma (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))) 1.0))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) + cbrt((1.0 + x))), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) + cbrt(Float64(1.0 + x))), 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 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[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, 1\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 9.2%
Taylor expanded in x around inf 94.7%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt2.8%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-commutative91.7%
log1p-undefine91.7%
exp-to-pow91.5%
metadata-eval91.5%
pow-prod-up91.5%
+-commutative91.5%
pow1/393.1%
+-commutative93.1%
pow1/398.3%
pow298.3%
+-commutative98.3%
Applied egg-rr98.3%
pow1/391.5%
add-sqr-sqrt91.5%
unpow-prod-down91.5%
add-sqr-sqrt91.5%
hypot-1-def91.5%
add-sqr-sqrt91.5%
hypot-1-def91.5%
Applied egg-rr91.5%
unpow1/393.0%
hypot-undefine93.0%
metadata-eval93.0%
rem-square-sqrt93.0%
unpow1/398.6%
hypot-undefine98.6%
metadata-eval98.6%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 19.9%
(FPCore (x) :precision binary64 (if (<= x 1.35e+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 <= 1.35e+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 <= 1.35e+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 <= 1.35e+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, 1.35e+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 1.35 \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 < 1.35000000000000003e154Initial program 9.2%
Taylor expanded in x around inf 94.7%
if 1.35000000000000003e154 < x Initial program 4.8%
flip3--4.8%
div-inv4.8%
rem-cube-cbrt2.8%
rem-cube-cbrt4.8%
+-commutative4.8%
distribute-rgt-out4.8%
+-commutative4.8%
fma-define4.8%
add-exp-log4.8%
Applied egg-rr4.8%
associate-*r/4.8%
*-rgt-identity4.8%
+-commutative4.8%
associate--l+91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-commutative91.7%
log1p-undefine91.7%
exp-to-pow91.5%
metadata-eval91.5%
pow-prod-up91.5%
+-commutative91.5%
pow1/393.1%
+-commutative93.1%
pow1/398.3%
pow298.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around 0 17.7%
(FPCore (x) :precision binary64 (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))))
double code(double x) {
return 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
}
public static double code(double x) {
return 0.3333333333333333 * Math.cbrt((1.0 / Math.pow(x, 2.0)));
}
function code(x) return Float64(0.3333333333333333 * cbrt(Float64(1.0 / (x ^ 2.0)))) end
code[x_] := N[(0.3333333333333333 * N[Power[N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \sqrt[3]{\frac{1}{{x}^{2}}}
\end{array}
Initial program 7.1%
Taylor expanded in x around inf 50.8%
(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 7.1%
Final simplification7.1%
(FPCore (x) :precision binary64 (cbrt x))
double code(double x) {
return cbrt(x);
}
public static double code(double x) {
return Math.cbrt(x);
}
function code(x) return cbrt(x) end
code[x_] := N[Power[x, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{x}
\end{array}
Initial program 7.1%
Taylor expanded in x around 0 1.8%
sub-neg1.8%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.4%
fabs-neg5.4%
unpow1/35.4%
metadata-eval5.4%
pow-sqr5.4%
fabs-sqr5.4%
pow-sqr5.4%
metadata-eval5.4%
unpow1/35.4%
Simplified5.4%
Taylor expanded in x around inf 5.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 7.1%
add-log-exp7.1%
Applied egg-rr7.1%
Taylor expanded in x around inf 4.2%
metadata-eval4.2%
Applied egg-rr4.2%
(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 2024180
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (cbrt (+ x 1)) (cbrt (+ x 1))) (* (cbrt x) (cbrt (+ x 1))) (* (cbrt x) (cbrt x)))))
(- (cbrt (+ x 1.0)) (cbrt x)))