{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;x \leq 7.4052989362426835:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\log \left(x + 1\right) - \log x}{n}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(FPCore (x n) :precision binary64 (if (<= x 7.4052989362426835) (expm1 (log1p (/ (- (log (+ x 1.0)) (log x)) n))) (/ (pow x (/ 1.0 n)) (* 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 tmp;
if (x <= 7.4052989362426835) {
tmp = expm1(log1p((log(x + 1.0) - log(x)) / n));
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}



Bits error versus x



Bits error versus n
Results
if x < 7.4052989362426835Initial program 47.0
Taylor expanded in n around inf 13.9
Applied expm1-log1p-u_binary6413.9
if 7.4052989362426835 < x Initial program 21.4
Taylor expanded in x around inf 1.6
Simplified1.6
Final simplification7.2
herbie shell --seed 2021215
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))