(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow (pow (cbrt x) 2.0) (/ 1.0 n)))
(t_1 (/ (log1p x) n))
(t_2 (exp t_1))
(t_3 (pow (cbrt x) (/ 1.0 n)))
(t_4 (/ (log x) n))
(t_5 (exp t_4))
(t_6 (* t_3 t_0)))
(if (<= (/ 1.0 n) -0.0002)
(- t_2 t_5)
(if (<= (/ 1.0 n) -2e-82)
(-
(fma
0.5
(/ (pow (log1p x) 2.0) (* n n))
(fma
0.041666666666666664
(/ (pow (log1p x) 4.0) (pow n 4.0))
(fma 0.16666666666666666 (pow t_1 3.0) t_1)))
(fma
0.16666666666666666
(pow t_4 3.0)
(fma
0.5
(/ (pow (log x) 2.0) (* n n))
(fma 0.041666666666666664 (/ (pow (log x) 4.0) (pow n 4.0)) t_4))))
(if (<= (/ 1.0 n) 2e-61)
(/ (- (log (/ (- x) (- -1.0 x)))) n)
(if (<= (/ 1.0 n) 0.02)
(/ t_5 (* n x))
(+ (fma 1.0 t_2 (- t_6)) (fma (- t_3) t_0 t_6))))))))double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
double code(double x, double n) {
double t_0 = pow(pow(cbrt(x), 2.0), (1.0 / n));
double t_1 = log1p(x) / n;
double t_2 = exp(t_1);
double t_3 = pow(cbrt(x), (1.0 / n));
double t_4 = log(x) / n;
double t_5 = exp(t_4);
double t_6 = t_3 * t_0;
double tmp;
if ((1.0 / n) <= -0.0002) {
tmp = t_2 - t_5;
} else if ((1.0 / n) <= -2e-82) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), fma(0.041666666666666664, (pow(log1p(x), 4.0) / pow(n, 4.0)), fma(0.16666666666666666, pow(t_1, 3.0), t_1))) - fma(0.16666666666666666, pow(t_4, 3.0), fma(0.5, (pow(log(x), 2.0) / (n * n)), fma(0.041666666666666664, (pow(log(x), 4.0) / pow(n, 4.0)), t_4)));
} else if ((1.0 / n) <= 2e-61) {
tmp = -log((-x / (-1.0 - x))) / n;
} else if ((1.0 / n) <= 0.02) {
tmp = t_5 / (n * x);
} else {
tmp = fma(1.0, t_2, -t_6) + fma(-t_3, t_0, t_6);
}
return tmp;
}
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function code(x, n) t_0 = (cbrt(x) ^ 2.0) ^ Float64(1.0 / n) t_1 = Float64(log1p(x) / n) t_2 = exp(t_1) t_3 = cbrt(x) ^ Float64(1.0 / n) t_4 = Float64(log(x) / n) t_5 = exp(t_4) t_6 = Float64(t_3 * t_0) tmp = 0.0 if (Float64(1.0 / n) <= -0.0002) tmp = Float64(t_2 - t_5); elseif (Float64(1.0 / n) <= -2e-82) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), fma(0.041666666666666664, Float64((log1p(x) ^ 4.0) / (n ^ 4.0)), fma(0.16666666666666666, (t_1 ^ 3.0), t_1))) - fma(0.16666666666666666, (t_4 ^ 3.0), fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), fma(0.041666666666666664, Float64((log(x) ^ 4.0) / (n ^ 4.0)), t_4)))); elseif (Float64(1.0 / n) <= 2e-61) tmp = Float64(Float64(-log(Float64(Float64(-x) / Float64(-1.0 - x)))) / n); elseif (Float64(1.0 / n) <= 0.02) tmp = Float64(t_5 / Float64(n * x)); else tmp = Float64(fma(1.0, t_2, Float64(-t_6)) + fma(Float64(-t_3), t_0, t_6)); end return tmp end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, n_] := Block[{t$95$0 = N[Power[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[Exp[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Power[x, 1/3], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$5 = N[Exp[t$95$4], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 * t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.0002], N[(t$95$2 - t$95$5), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-82], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[Power[t$95$1, 3.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * N[Power[t$95$4, 3.0], $MachinePrecision] + N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-61], N[((-N[Log[N[((-x) / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.02], N[(t$95$5 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * t$95$2 + (-t$95$6)), $MachinePrecision] + N[((-t$95$3) * t$95$0 + t$95$6), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_2 := e^{t_1}\\
t_3 := {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\\
t_4 := \frac{\log x}{n}\\
t_5 := e^{t_4}\\
t_6 := t_3 \cdot t_0\\
\mathbf{if}\;\frac{1}{n} \leq -0.0002:\\
\;\;\;\;t_2 - t_5\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-82}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {t_1}^{3}, t_1\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {t_4}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, t_4\right)\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-61}:\\
\;\;\;\;\frac{-\log \left(\frac{-x}{-1 - x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.02:\\
\;\;\;\;\frac{t_5}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, t_2, -t_6\right) + \mathsf{fma}\left(-t_3, t_0, t_6\right)\\
\end{array}



Bits error versus x



Bits error versus n
if (/.f64 1 n) < -2.0000000000000001e-4Initial program 0.5
Taylor expanded in n around 0 0.5
Simplified0.5
if -2.0000000000000001e-4 < (/.f64 1 n) < -2e-82Initial program 54.7
Taylor expanded in n around inf 25.8
Simplified25.8
if -2e-82 < (/.f64 1 n) < 2.0000000000000001e-61Initial program 41.6
Taylor expanded in n around inf 11.0
Simplified11.0
Applied egg-rr10.9
Applied egg-rr10.9
Applied egg-rr10.9
if 2.0000000000000001e-61 < (/.f64 1 n) < 0.0200000000000000004Initial program 51.8
Taylor expanded in x around inf 32.6
Simplified32.6
if 0.0200000000000000004 < (/.f64 1 n) Initial program 4.4
Applied egg-rr0.8
Final simplification11.1
herbie shell --seed 2022166
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))