{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_2 := \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {t_1}^{3}, t_1\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {t_0}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, t_0\right)\right)\right)\\
\mathbf{if}\;n \leq -1.041250944500129 \cdot 10^{+126}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := {x}^{\left(\frac{1}{n}\right)}\\
t_4 := \frac{t_3}{n \cdot x}\\
\mathbf{if}\;n \leq -24500527.02708143:\\
\;\;\;\;t_4\\
\mathbf{elif}\;n \leq 71783639.15478234:\\
\;\;\;\;\begin{array}{l}
t_5 := e^{t_1}\\
\sqrt[3]{{\left(t_5 - e^{t_0}\right)}^{2}} \cdot \sqrt[3]{t_5 - t_3}
\end{array}\\
\mathbf{elif}\;n \leq 1.2314344705355872 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
t_6 := n \cdot {x}^{3}\\
\mathsf{fma}\left(0.3333333333333333, \frac{t_3}{t_6}, \mathsf{fma}\left(0.5, \frac{t_3}{\left(n \cdot n\right) \cdot \left(x \cdot x\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{t_3}{{x}^{3} \cdot {n}^{3}}, t_4\right)\right)\right) - 0.5 \cdot \left(\frac{t_3}{x \cdot \left(n \cdot x\right)} + \frac{t_3}{n \cdot t_6}\right)
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\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 (/ (log x) n))
(t_1 (/ (log1p x) n))
(t_2
(-
(fma
0.5
(/ (pow (log1p x) 2.0) (* n n))
(fma
0.041666666666666664
(/ (pow (log1p x) 4.0) (pow n 4.0))
(fma 0.16666666666666666 (pow t_1 3.0) t_1)))
(fma
0.16666666666666666
(pow t_0 3.0)
(fma
0.5
(/ (pow (log x) 2.0) (* n n))
(fma
0.041666666666666664
(/ (pow (log x) 4.0) (pow n 4.0))
t_0))))))
(if (<= n -1.041250944500129e+126)
t_2
(let* ((t_3 (pow x (/ 1.0 n))) (t_4 (/ t_3 (* n x))))
(if (<= n -24500527.02708143)
t_4
(if (<= n 71783639.15478234)
(let* ((t_5 (exp t_1)))
(* (cbrt (pow (- t_5 (exp t_0)) 2.0)) (cbrt (- t_5 t_3))))
(if (<= n 1.2314344705355872e+64)
(let* ((t_6 (* n (pow x 3.0))))
(-
(fma
0.3333333333333333
(/ t_3 t_6)
(fma
0.5
(/ t_3 (* (* n n) (* x x)))
(fma
0.16666666666666666
(/ t_3 (* (pow x 3.0) (pow n 3.0)))
t_4)))
(* 0.5 (+ (/ t_3 (* x (* n x))) (/ t_3 (* n t_6))))))
t_2)))))))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 = log(x) / n;
double t_1 = log1p(x) / n;
double t_2 = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), fma(0.041666666666666664, (pow(log1p(x), 4.0) / pow(n, 4.0)), fma(0.16666666666666666, pow(t_1, 3.0), t_1))) - fma(0.16666666666666666, pow(t_0, 3.0), fma(0.5, (pow(log(x), 2.0) / (n * n)), fma(0.041666666666666664, (pow(log(x), 4.0) / pow(n, 4.0)), t_0)));
double tmp;
if (n <= -1.041250944500129e+126) {
tmp = t_2;
} else {
double t_3 = pow(x, (1.0 / n));
double t_4 = t_3 / (n * x);
double tmp_1;
if (n <= -24500527.02708143) {
tmp_1 = t_4;
} else if (n <= 71783639.15478234) {
double t_5 = exp(t_1);
tmp_1 = cbrt(pow((t_5 - exp(t_0)), 2.0)) * cbrt(t_5 - t_3);
} else if (n <= 1.2314344705355872e+64) {
double t_6 = n * pow(x, 3.0);
tmp_1 = fma(0.3333333333333333, (t_3 / t_6), fma(0.5, (t_3 / ((n * n) * (x * x))), fma(0.16666666666666666, (t_3 / (pow(x, 3.0) * pow(n, 3.0))), t_4))) - (0.5 * ((t_3 / (x * (n * x))) + (t_3 / (n * t_6))));
} else {
tmp_1 = t_2;
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus x



Bits error versus n
if n < -1.041250944500129e126 or 1.2314344705355872e64 < n Initial program 41.2
Taylor expanded in n around inf 10.3
Simplified10.4
if -1.041250944500129e126 < n < -24500527.02708143Initial program 54.0
Taylor expanded in x around inf 32.9
Simplified32.9
if -24500527.02708143 < n < 71783639.1547823399Initial program 3.2
Applied add-cube-cbrt_binary643.2
Simplified3.1
Simplified2.1
Taylor expanded in n around 0 2.1
Simplified2.1
if 71783639.1547823399 < n < 1.2314344705355872e64Initial program 54.8
Taylor expanded in x around inf 30.9
Simplified30.9
Final simplification12.5
herbie shell --seed 2022024
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))