{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\\
t_1 := {\log x}^{2}\\
\mathbf{if}\;x \leq 1.765246649597966 \cdot 10^{-276}:\\
\;\;\;\;\frac{1}{\frac{\left(\log x + \mathsf{log1p}\left(x\right)\right) \cdot n}{t_0 - t_1}}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 4.641095742691318 \cdot 10^{-262}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_2\\
\mathbf{elif}\;x \leq 5540.777704054234:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_4 := \frac{\log x}{n}\\
\mathsf{fma}\left(0.5, \frac{t_0}{n \cdot n}, \mathsf{fma}\left(0.16666666666666666, {t_3}^{3}, t_3\right)\right) - \mathsf{fma}\left(0.16666666666666666, {t_4}^{3}, \mathsf{fma}\left(0.5, \frac{t_1}{n \cdot n}, t_4\right)\right)
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2}{x \cdot n}\\
\end{array}\\
\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 (log1p x) 2.0)) (t_1 (pow (log x) 2.0)))
(if (<= x 1.765246649597966e-276)
(/ 1.0 (/ (* (+ (log x) (log1p x)) n) (- t_0 t_1)))
(let* ((t_2 (pow x (/ 1.0 n))))
(if (<= x 4.641095742691318e-262)
(- (pow (+ x 1.0) (/ 1.0 n)) t_2)
(if (<= x 5540.777704054234)
(let* ((t_3 (/ (log1p x) n)) (t_4 (/ (log x) n)))
(-
(fma
0.5
(/ t_0 (* n n))
(fma 0.16666666666666666 (pow t_3 3.0) t_3))
(fma
0.16666666666666666
(pow t_4 3.0)
(fma 0.5 (/ t_1 (* n n)) t_4))))
(/ t_2 (* 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 = pow(log1p(x), 2.0);
double t_1 = pow(log(x), 2.0);
double tmp;
if (x <= 1.765246649597966e-276) {
tmp = 1.0 / (((log(x) + log1p(x)) * n) / (t_0 - t_1));
} else {
double t_2 = pow(x, (1.0 / n));
double tmp_1;
if (x <= 4.641095742691318e-262) {
tmp_1 = pow((x + 1.0), (1.0 / n)) - t_2;
} else if (x <= 5540.777704054234) {
double t_3 = log1p(x) / n;
double t_4 = log(x) / n;
tmp_1 = fma(0.5, (t_0 / (n * n)), fma(0.16666666666666666, pow(t_3, 3.0), t_3)) - fma(0.16666666666666666, pow(t_4, 3.0), fma(0.5, (t_1 / (n * n)), t_4));
} else {
tmp_1 = t_2 / (x * n);
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus x



Bits error versus n
if x < 1.76524664959796603e-276Initial program 39.7
Taylor expanded in n around inf 21.2
Simplified21.2
Applied clear-num_binary6421.3
Applied flip--_binary6421.3
Applied associate-/r/_binary6421.3
Simplified21.3
Applied pow1_binary6421.3
Applied pow1_binary6421.3
Applied pow-prod-down_binary6421.3
Simplified21.4
if 1.76524664959796603e-276 < x < 4.6410957426913177e-262Initial program 39.5
if 4.6410957426913177e-262 < x < 5540.77770405423416Initial program 48.3
Taylor expanded in n around inf 12.2
Simplified12.2
if 5540.77770405423416 < x Initial program 20.6
Taylor expanded in x around inf 1.4
Simplified1.4
Final simplification7.6
herbie shell --seed 2021313
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))