(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 (/ (log1p x) n)) (t_1 (/ (log x) n)))
(if (<= x 1.3156010340719408e-288)
(-
(fma
0.5
(/ (pow (log1p x) 2.0) (* n n))
(fma 0.16666666666666666 (pow t_0 3.0) t_0))
(fma
0.16666666666666666
(pow t_1 3.0)
(fma 0.5 (/ (pow (log x) 2.0) (* n n)) t_1)))
(if (<= x 1.2988131937612738e-262)
(fma -1.0 (pow x (/ 1.0 n)) (exp t_0))
(if (<= x 9705.140304668308)
(/ (- (log1p x) (log x)) n)
(/ (exp t_1) (* x n)))))))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 = log1p(x) / n;
double t_1 = log(x) / n;
double tmp;
if (x <= 1.3156010340719408e-288) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), fma(0.16666666666666666, pow(t_0, 3.0), t_0)) - fma(0.16666666666666666, pow(t_1, 3.0), fma(0.5, (pow(log(x), 2.0) / (n * n)), t_1));
} else if (x <= 1.2988131937612738e-262) {
tmp = fma(-1.0, pow(x, (1.0 / n)), exp(t_0));
} else if (x <= 9705.140304668308) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp(t_1) / (x * n);
}
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 = Float64(log1p(x) / n) t_1 = Float64(log(x) / n) tmp = 0.0 if (x <= 1.3156010340719408e-288) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), fma(0.16666666666666666, (t_0 ^ 3.0), t_0)) - fma(0.16666666666666666, (t_1 ^ 3.0), fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), t_1))); elseif (x <= 1.2988131937612738e-262) tmp = fma(-1.0, (x ^ Float64(1.0 / n)), exp(t_0)); elseif (x <= 9705.140304668308) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(t_1) / Float64(x * n)); 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[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 1.3156010340719408e-288], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[Power[t$95$0, 3.0], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * N[Power[t$95$1, 3.0], $MachinePrecision] + N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2988131937612738e-262], N[(-1.0 * N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] + N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9705.140304668308], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[t$95$1], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_1 := \frac{\log x}{n}\\
\mathbf{if}\;x \leq 1.3156010340719408 \cdot 10^{-288}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.16666666666666666, {t_0}^{3}, t_0\right)\right) - \mathsf{fma}\left(0.16666666666666666, {t_1}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, t_1\right)\right)\\
\mathbf{elif}\;x \leq 1.2988131937612738 \cdot 10^{-262}:\\
\;\;\;\;\mathsf{fma}\left(-1, {x}^{\left(\frac{1}{n}\right)}, e^{t_0}\right)\\
\mathbf{elif}\;x \leq 9705.140304668308:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{t_1}}{x \cdot n}\\
\end{array}



Bits error versus x



Bits error versus n
if x < 1.3156010340719408e-288Initial program 40.6
Taylor expanded in n around inf 20.0
Simplified20.0
if 1.3156010340719408e-288 < x < 1.29881319376127382e-262Initial program 37.7
Applied egg-rr37.4
if 1.29881319376127382e-262 < x < 9705.1403046683081Initial program 49.2
Taylor expanded in n around inf 11.8
Simplified11.8
Applied egg-rr11.8
Applied egg-rr11.8
if 9705.1403046683081 < x Initial program 21.3
Taylor expanded in x around inf 1.5
Simplified1.5
Final simplification7.5
herbie shell --seed 2022150
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))