{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -1.4696895820278125 \cdot 10^{-41}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5.809244467416722 \cdot 10^{-171}:\\
\;\;\;\;-\frac{\log \left(\frac{-x}{-1 - x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.6142285024081105 \cdot 10^{-120}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 8.796742391996114 \cdot 10^{-68}:\\
\;\;\;\;-\frac{\log \left(x \cdot \frac{1}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 9.870267292048051 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(\left(\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}\right) - \frac{0.5}{x \cdot x}\right) - \frac{0.25}{{x}^{4}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.334499698959325 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{n} \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 0.26333508773832487:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
(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 x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -1.4696895820278125e-41)
t_1
(if (<= (/ 1.0 n) 5.809244467416722e-171)
(- (/ (log (/ (- x) (- -1.0 x))) n))
(if (<= (/ 1.0 n) 1.6142285024081105e-120)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 8.796742391996114e-68)
(- (/ (log (* x (/ 1.0 (+ 1.0 x)))) n))
(if (<= (/ 1.0 n) 9.870267292048051e-35)
(/
(-
(-
(+ (/ 1.0 x) (/ 0.3333333333333333 (pow x 3.0)))
(/ 0.5 (* x x)))
(/ 0.25 (pow x 4.0)))
n)
(if (<= (/ 1.0 n) 1.334499698959325e-25)
(* (/ 1.0 n) (- (log1p x) (log x)))
(if (<= (/ 1.0 n) 0.26333508773832487)
t_1
(- (exp (/ (log1p x) n)) t_0))))))))))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(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -1.4696895820278125e-41) {
tmp = t_1;
} else if ((1.0 / n) <= 5.809244467416722e-171) {
tmp = -(log(-x / (-1.0 - x)) / n);
} else if ((1.0 / n) <= 1.6142285024081105e-120) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 8.796742391996114e-68) {
tmp = -(log(x * (1.0 / (1.0 + x))) / n);
} else if ((1.0 / n) <= 9.870267292048051e-35) {
tmp = ((((1.0 / x) + (0.3333333333333333 / pow(x, 3.0))) - (0.5 / (x * x))) - (0.25 / pow(x, 4.0))) / n;
} else if ((1.0 / n) <= 1.334499698959325e-25) {
tmp = (1.0 / n) * (log1p(x) - log(x));
} else if ((1.0 / n) <= 0.26333508773832487) {
tmp = t_1;
} else {
tmp = exp(log1p(x) / n) - t_0;
}
return tmp;
}



Bits error versus x



Bits error versus n
Results
if (/.f64 1 n) < -1.46968958202781248e-41 or 1.3344996989593251e-25 < (/.f64 1 n) < 0.263335087738324869Initial program 13.9
Taylor expanded in x around inf 9.1
Simplified9.1
if -1.46968958202781248e-41 < (/.f64 1 n) < 5.8092444674167221e-171Initial program 41.3
Taylor expanded in n around -inf 10.5
Simplified10.5
Applied log1p-udef_binary6410.5
Applied diff-log_binary6410.3
Applied frac-2neg_binary6410.3
Simplified10.3
if 5.8092444674167221e-171 < (/.f64 1 n) < 1.6142285024081105e-120Initial program 46.5
Taylor expanded in n around -inf 16.7
Simplified16.7
Taylor expanded in x around inf 29.5
if 1.6142285024081105e-120 < (/.f64 1 n) < 8.7967423919961143e-68Initial program 52.2
Taylor expanded in n around -inf 22.6
Simplified22.6
Applied log1p-udef_binary6422.6
Applied diff-log_binary6422.5
Applied div-inv_binary6424.0
Simplified24.0
if 8.7967423919961143e-68 < (/.f64 1 n) < 9.87026729204805135e-35Initial program 56.7
Taylor expanded in n around -inf 26.5
Simplified26.5
Taylor expanded in x around inf 31.4
Simplified31.4
if 9.87026729204805135e-35 < (/.f64 1 n) < 1.3344996989593251e-25Initial program 59.4
Taylor expanded in n around -inf 27.2
Simplified27.2
Applied div-inv_binary6427.2
if 0.263335087738324869 < (/.f64 1 n) Initial program 4.4
Taylor expanded in n around 0 4.4
Simplified0.5
Final simplification12.1
herbie shell --seed 2021224
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))