{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2.2779687884622282 \cdot 10^{-19}:\\
\;\;\;\;\frac{e^{-\frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2.8270861523315105 \cdot 10^{-23}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\frac{\log x}{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 (<= (/ 1.0 n) -2.2779687884622282e-19)
(/ (exp (- (/ (log (/ 1.0 x)) n))) (* n x))
(if (<= (/ 1.0 n) 2.8270861523315105e-23)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ (log1p x) n)) (exp (/ (log 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 ((1.0 / n) <= -2.2779687884622282e-19) {
tmp = exp(-(log(1.0 / x) / n)) / (n * x);
} else if ((1.0 / n) <= 2.8270861523315105e-23) {
tmp = log((1.0 + x) / x) / n;
} else {
tmp = exp(log1p(x) / n) - exp(log(x) / n);
}
return tmp;
}



Bits error versus x



Bits error versus n
Results
if (/.f64 1 n) < -2.2779687884622282e-19Initial program 4.0
Taylor expanded in x around inf 3.3
if -2.2779687884622282e-19 < (/.f64 1 n) < 2.8270861523315105e-23Initial program 44.1
Taylor expanded in n around inf 13.4
Simplified13.4
Applied log1p-udef_binary6413.4
Applied diff-log_binary6413.3
Simplified13.3
if 2.8270861523315105e-23 < (/.f64 1 n) Initial program 12.4
Taylor expanded in n around 0 12.4
Simplified9.6
Final simplification10.9
herbie shell --seed 2022068
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))