
(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 (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 7.6%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt7.1%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.2%
+-commutative93.2%
+-commutative93.2%
Simplified93.2%
*-commutative93.2%
log1p-undefine93.2%
exp-to-pow93.1%
metadata-eval93.1%
pow-prod-up93.2%
+-commutative93.2%
pow1/394.6%
+-commutative94.6%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
pow1/394.6%
add-sqr-sqrt94.6%
unpow-prod-down94.6%
add-sqr-sqrt94.6%
hypot-1-def94.6%
add-sqr-sqrt94.6%
hypot-1-def94.6%
Applied egg-rr94.6%
unpow1/396.0%
hypot-undefine96.0%
metadata-eval96.0%
rem-square-sqrt96.0%
unpow1/398.4%
hypot-undefine98.4%
metadata-eval98.4%
rem-square-sqrt98.4%
Simplified98.4%
Taylor expanded in x around 0 98.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 7.6%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt7.1%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.2%
+-commutative93.2%
+-commutative93.2%
Simplified93.2%
*-commutative93.2%
log1p-undefine93.2%
exp-to-pow93.1%
metadata-eval93.1%
pow-prod-up93.2%
+-commutative93.2%
pow1/394.6%
+-commutative94.6%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))))
(if (<= x 2e+14)
(/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow (+ 1.0 x) 0.6666666666666666)))
(/ (+ 1.0 (- x x)) (fma (cbrt x) (* (cbrt x) 2.0) (pow t_0 2.0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double tmp;
if (x <= 2e+14) {
tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow((1.0 + x), 0.6666666666666666));
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) * 2.0), pow(t_0, 2.0));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) tmp = 0.0 if (x <= 2e+14) tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (Float64(1.0 + x) ^ 0.6666666666666666))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) * 2.0), (t_0 ^ 2.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 2e+14], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $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[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t\_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {t\_0}^{2}\right)}\\
\end{array}
\end{array}
if x < 2e14Initial program 65.2%
flip3--70.5%
div-inv70.5%
rem-cube-cbrt73.4%
rem-cube-cbrt99.3%
+-commutative99.3%
distribute-rgt-out98.9%
+-commutative98.9%
fma-define98.9%
add-exp-log99.1%
Applied egg-rr99.0%
associate-*r/99.0%
*-rgt-identity99.0%
+-commutative99.0%
associate--l+99.0%
+-commutative99.0%
+-commutative99.0%
Simplified99.0%
*-commutative99.0%
log1p-undefine99.0%
exp-to-pow98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 98.4%
if 2e14 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.3%
rem-cube-cbrt4.6%
+-commutative4.6%
distribute-rgt-out4.6%
+-commutative4.6%
fma-define4.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
+-commutative4.6%
associate--l+92.9%
+-commutative92.9%
+-commutative92.9%
Simplified92.9%
*-commutative92.9%
log1p-undefine92.9%
exp-to-pow92.8%
metadata-eval92.8%
pow-prod-up92.8%
+-commutative92.8%
pow1/394.4%
+-commutative94.4%
pow1/398.3%
pow298.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.3%
*-commutative98.3%
Simplified98.3%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ (+ 1.0 (- x x)) (+ (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 + (x - x)) / (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 + (x - x)) / (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(Float64(1.0 + Float64(x - x)) / 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[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / 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 + \left(x - x\right)}{{t\_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t\_0\right)}
\end{array}
\end{array}
Initial program 7.6%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt7.1%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.2%
+-commutative93.2%
+-commutative93.2%
Simplified93.2%
*-commutative93.2%
log1p-undefine93.2%
exp-to-pow93.1%
metadata-eval93.1%
pow-prod-up93.2%
+-commutative93.2%
pow1/394.6%
+-commutative94.6%
pow1/398.4%
add-sqr-sqrt98.4%
associate-*r*98.3%
Applied egg-rr96.0%
*-commutative96.0%
Simplified96.0%
fma-undefine96.0%
pow1/296.0%
pow-prod-up93.2%
metadata-eval93.2%
metadata-eval93.2%
pow-sqr93.2%
pow1/394.7%
pow1/398.4%
+-commutative98.4%
pow298.4%
Applied egg-rr98.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 7.6%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt7.1%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.2%
+-commutative93.2%
+-commutative93.2%
Simplified93.2%
*-commutative93.2%
log1p-undefine93.2%
exp-to-pow93.1%
Applied egg-rr93.1%
Taylor expanded in x around 0 93.1%
(FPCore (x)
:precision binary64
(if (<= x 1.35e+154)
(/
(+
(* (cbrt x) -0.1111111111111111)
(* 0.3333333333333333 (pow (cbrt x) 4.0)))
(pow x 2.0))
(/
(+ 1.0 (- x x))
(fma (cbrt x) (* (cbrt x) 2.0) (pow (+ 1.0 x) 0.6666666666666666)))))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = ((cbrt(x) * -0.1111111111111111) + (0.3333333333333333 * pow(cbrt(x), 4.0))) / pow(x, 2.0);
} else {
tmp = (1.0 + (x - x)) / fma(cbrt(x), (cbrt(x) * 2.0), pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(Float64(cbrt(x) * -0.1111111111111111) + Float64(0.3333333333333333 * (cbrt(x) ^ 4.0))) / (x ^ 2.0)); else tmp = Float64(Float64(1.0 + Float64(x - x)) / fma(cbrt(x), Float64(cbrt(x) * 2.0), (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(N[(N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], 4.0], $MachinePrecision]), $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] * 2.0), $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{\sqrt[3]{x} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{4}}{{x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} \cdot 2, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 10.4%
Taylor expanded in x around inf 58.4%
pow1/354.3%
metadata-eval54.3%
pow-prod-up54.3%
unpow-prod-down88.4%
pow1/389.9%
unpow289.9%
cbrt-prod89.9%
pow289.9%
pow1/395.7%
unpow295.7%
cbrt-prod95.0%
pow295.0%
Applied egg-rr95.0%
pow-sqr95.0%
metadata-eval95.0%
Simplified95.0%
if 1.35000000000000003e154 < 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%
+-commutative91.9%
+-commutative91.9%
Simplified91.9%
*-commutative91.9%
log1p-undefine91.9%
exp-to-pow91.6%
Applied egg-rr91.6%
Taylor expanded in x around inf 91.6%
*-commutative98.4%
Simplified91.6%
Final simplification93.3%
(FPCore (x)
:precision binary64
(if (<= x 1.35e+154)
(/
(+
(* (cbrt x) -0.1111111111111111)
(* 0.3333333333333333 (pow (cbrt x) 4.0)))
(pow x 2.0))
(pow (/ 1.0 (* (cbrt x) (sqrt 2.0))) 2.0)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = ((cbrt(x) * -0.1111111111111111) + (0.3333333333333333 * pow(cbrt(x), 4.0))) / pow(x, 2.0);
} else {
tmp = pow((1.0 / (cbrt(x) * sqrt(2.0))), 2.0);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = ((Math.cbrt(x) * -0.1111111111111111) + (0.3333333333333333 * Math.pow(Math.cbrt(x), 4.0))) / Math.pow(x, 2.0);
} else {
tmp = Math.pow((1.0 / (Math.cbrt(x) * Math.sqrt(2.0))), 2.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(Float64(cbrt(x) * -0.1111111111111111) + Float64(0.3333333333333333 * (cbrt(x) ^ 4.0))) / (x ^ 2.0)); else tmp = Float64(1.0 / Float64(cbrt(x) * sqrt(2.0))) ^ 2.0; end return tmp end
code[x_] := If[LessEqual[x, 1.35e+154], N[(N[(N[(N[Power[x, 1/3], $MachinePrecision] * -0.1111111111111111), $MachinePrecision] + N[(0.3333333333333333 * N[Power[N[Power[x, 1/3], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], N[Power[N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{\sqrt[3]{x} \cdot -0.1111111111111111 + 0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{4}}{{x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{\sqrt[3]{x} \cdot \sqrt{2}}\right)}^{2}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 10.4%
Taylor expanded in x around inf 58.4%
pow1/354.3%
metadata-eval54.3%
pow-prod-up54.3%
unpow-prod-down88.4%
pow1/389.9%
unpow289.9%
cbrt-prod89.9%
pow289.9%
pow1/395.7%
unpow295.7%
cbrt-prod95.0%
pow295.0%
Applied egg-rr95.0%
pow-sqr95.0%
metadata-eval95.0%
Simplified95.0%
if 1.35000000000000003e154 < 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%
+-commutative91.9%
+-commutative91.9%
Simplified91.9%
*-commutative91.9%
log1p-undefine91.9%
exp-to-pow91.6%
metadata-eval91.6%
pow-prod-up91.6%
+-commutative91.6%
pow1/393.2%
+-commutative93.2%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Applied egg-rr91.0%
Taylor expanded in x around inf 20.0%
Final simplification57.8%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (pow (/ 1.0 (* (cbrt x) (sqrt 2.0))) 2.0)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = pow((1.0 / (cbrt(x) * sqrt(2.0))), 2.0);
}
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 = Math.pow((1.0 / (Math.cbrt(x) * Math.sqrt(2.0))), 2.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(1.0 / Float64(cbrt(x) * sqrt(2.0))) ^ 2.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[Power[N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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}:\\
\;\;\;\;{\left(\frac{1}{\sqrt[3]{x} \cdot \sqrt{2}}\right)}^{2}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 10.4%
Taylor expanded in x around inf 93.9%
if 1.35000000000000003e154 < 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%
+-commutative91.9%
+-commutative91.9%
Simplified91.9%
*-commutative91.9%
log1p-undefine91.9%
exp-to-pow91.6%
metadata-eval91.6%
pow-prod-up91.6%
+-commutative91.6%
pow1/393.2%
+-commutative93.2%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Applied egg-rr91.0%
Taylor expanded in x around inf 20.0%
(FPCore (x) :precision binary64 (if (<= x 1.35e+154) (* 0.3333333333333333 (cbrt (/ 1.0 (pow x 2.0)))) (pow (* (cbrt (/ 1.0 x)) (sqrt 0.5)) 2.0)))
double code(double x) {
double tmp;
if (x <= 1.35e+154) {
tmp = 0.3333333333333333 * cbrt((1.0 / pow(x, 2.0)));
} else {
tmp = pow((cbrt((1.0 / x)) * sqrt(0.5)), 2.0);
}
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 = Math.pow((Math.cbrt((1.0 / x)) * Math.sqrt(0.5)), 2.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(cbrt(Float64(1.0 / x)) * sqrt(0.5)) ^ 2.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[Power[N[(N[Power[N[(1.0 / x), $MachinePrecision], 1/3], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], 2.0], $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}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{1}{x}} \cdot \sqrt{0.5}\right)}^{2}\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 10.4%
Taylor expanded in x around inf 93.9%
if 1.35000000000000003e154 < 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%
+-commutative91.9%
+-commutative91.9%
Simplified91.9%
*-commutative91.9%
log1p-undefine91.9%
exp-to-pow91.6%
metadata-eval91.6%
pow-prod-up91.6%
+-commutative91.6%
pow1/393.2%
+-commutative93.2%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Applied egg-rr91.0%
Taylor expanded in x around inf 20.0%
(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 10.4%
Taylor expanded in x around inf 93.9%
if 1.35000000000000003e154 < 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%
+-commutative91.9%
+-commutative91.9%
Simplified91.9%
*-commutative91.9%
log1p-undefine91.9%
exp-to-pow91.6%
metadata-eval91.6%
pow-prod-up91.6%
+-commutative91.6%
pow1/393.2%
+-commutative93.2%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 17.7%
(FPCore (x) :precision binary64 (if (<= x 1.1e+15) (- (cbrt (+ 1.0 x)) (cbrt x)) (* 0.5 (cbrt (pow x -2.0)))))
double code(double x) {
double tmp;
if (x <= 1.1e+15) {
tmp = cbrt((1.0 + x)) - cbrt(x);
} else {
tmp = 0.5 * cbrt(pow(x, -2.0));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.1e+15) {
tmp = Math.cbrt((1.0 + x)) - Math.cbrt(x);
} else {
tmp = 0.5 * Math.cbrt(Math.pow(x, -2.0));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.1e+15) tmp = Float64(cbrt(Float64(1.0 + x)) - cbrt(x)); else tmp = Float64(0.5 * cbrt((x ^ -2.0))); end return tmp end
code[x_] := If[LessEqual[x, 1.1e+15], N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[N[Power[x, -2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{+15}:\\
\;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt[3]{{x}^{-2}}\\
\end{array}
\end{array}
if x < 1.1e15Initial program 65.2%
if 1.1e15 < x Initial program 4.2%
flip3--4.2%
div-inv4.2%
rem-cube-cbrt3.3%
rem-cube-cbrt4.6%
+-commutative4.6%
distribute-rgt-out4.6%
+-commutative4.6%
fma-define4.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
+-commutative4.6%
associate--l+92.9%
+-commutative92.9%
+-commutative92.9%
Simplified92.9%
*-commutative92.9%
log1p-undefine92.9%
exp-to-pow92.8%
metadata-eval92.8%
pow-prod-up92.8%
+-commutative92.8%
pow1/394.4%
+-commutative94.4%
pow1/398.3%
pow298.3%
+-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 12.0%
unpow-112.0%
exp-to-pow12.0%
*-commutative12.0%
exp-prod12.3%
*-commutative12.3%
associate-*r*12.3%
metadata-eval12.3%
*-commutative12.3%
exp-to-pow12.3%
Simplified12.3%
Final simplification15.2%
(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.6%
Taylor expanded in x around inf 49.7%
(FPCore (x) :precision binary64 (* 0.5 (cbrt (pow x -2.0))))
double code(double x) {
return 0.5 * cbrt(pow(x, -2.0));
}
public static double code(double x) {
return 0.5 * Math.cbrt(Math.pow(x, -2.0));
}
function code(x) return Float64(0.5 * cbrt((x ^ -2.0))) end
code[x_] := N[(0.5 * N[Power[N[Power[x, -2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \sqrt[3]{{x}^{-2}}
\end{array}
Initial program 7.6%
flip3--7.9%
div-inv7.9%
rem-cube-cbrt7.1%
rem-cube-cbrt9.7%
+-commutative9.7%
distribute-rgt-out9.7%
+-commutative9.7%
fma-define9.7%
add-exp-log9.7%
Applied egg-rr9.7%
associate-*r/9.7%
*-rgt-identity9.7%
+-commutative9.7%
associate--l+93.2%
+-commutative93.2%
+-commutative93.2%
Simplified93.2%
*-commutative93.2%
log1p-undefine93.2%
exp-to-pow93.1%
metadata-eval93.1%
pow-prod-up93.2%
+-commutative93.2%
pow1/394.6%
+-commutative94.6%
pow1/398.4%
pow298.4%
+-commutative98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 12.4%
unpow-112.4%
exp-to-pow12.4%
*-commutative12.4%
exp-prod12.7%
*-commutative12.7%
associate-*r*12.7%
metadata-eval12.7%
*-commutative12.7%
exp-to-pow12.7%
Simplified12.7%
(FPCore (x) :precision binary64 (* x (+ (/ 1.0 x) (cbrt (/ 1.0 (* x x))))))
double code(double x) {
return x * ((1.0 / x) + cbrt((1.0 / (x * x))));
}
public static double code(double x) {
return x * ((1.0 / x) + Math.cbrt((1.0 / (x * x))));
}
function code(x) return Float64(x * Float64(Float64(1.0 / x) + cbrt(Float64(1.0 / Float64(x * x))))) end
code[x_] := N[(x * N[(N[(1.0 / x), $MachinePrecision] + N[Power[N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{1}{x} + \sqrt[3]{\frac{1}{x \cdot x}}\right)
\end{array}
Initial program 7.6%
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%
Taylor expanded in x around inf 5.9%
unpow25.9%
Applied egg-rr5.9%
Final simplification5.9%
(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.6%
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%
Taylor expanded in x around inf 5.5%
(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 2024163
(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)))