{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := \sqrt[3]{\left(x + n\right) - n}\\
t_1 := e^{-1 \cdot \frac{-\log x}{n}}\\
\mathbf{if}\;x \leq -2.9019362550020532 \cdot 10^{+193}:\\
\;\;\;\;\frac{\frac{x}{\sqrt[3]{n \cdot n}}}{\sqrt[3]{n}}\\
\mathbf{elif}\;x \leq 1.846802285931436 \cdot 10^{-308}:\\
\;\;\;\;\frac{\mathsf{fma}\left({t_0}^{2}, t_0, 0\right)}{n}\\
\mathbf{elif}\;x \leq 1.2179570994719419 \cdot 10^{-236}:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;x \leq 4.616680033797104 \cdot 10^{-189}:\\
\;\;\;\;{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}\\
\mathbf{elif}\;x \leq 808.4781327219058:\\
\;\;\;\;-1 \cdot \frac{\log x - \mathsf{log1p}\left(x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.4583333333333333, \frac{t_1}{\left(n \cdot n\right) \cdot {x}^{4}}, \mathsf{fma}\left(0.3333333333333333, \frac{t_1}{n \cdot {x}^{3}}, \mathsf{fma}\left(0.041666666666666664, \frac{t_1}{{x}^{4} \cdot {n}^{4}}, \mathsf{fma}\left(0.5, \frac{t_1}{\left(x \cdot x\right) \cdot \left(n \cdot n\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{t_1}{{x}^{3} \cdot {n}^{3}}, \frac{t_1}{x \cdot n}\right)\right)\right)\right)\right) - \mathsf{fma}\left(0.25, \frac{t_1}{n \cdot {x}^{4}} + \frac{t_1}{{n}^{3} \cdot {x}^{4}}, 0.5 \cdot \left(\frac{t_1}{n \cdot \left(x \cdot x\right)} + \frac{t_1}{\left(n \cdot n\right) \cdot {x}^{3}}\right)\right)\\
\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 (cbrt (- (+ x n) n))) (t_1 (exp (* -1.0 (/ (- (log x)) n)))))
(if (<= x -2.9019362550020532e+193)
(/ (/ x (cbrt (* n n))) (cbrt n))
(if (<= x 1.846802285931436e-308)
(/ (fma (pow t_0 2.0) t_0 0.0) n)
(if (<= x 1.2179570994719419e-236)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= x 4.616680033797104e-189)
(pow (sqrt (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))) 2.0)
(if (<= x 808.4781327219058)
(* -1.0 (/ (- (log x) (log1p x)) n))
(-
(fma
0.4583333333333333
(/ t_1 (* (* n n) (pow x 4.0)))
(fma
0.3333333333333333
(/ t_1 (* n (pow x 3.0)))
(fma
0.041666666666666664
(/ t_1 (* (pow x 4.0) (pow n 4.0)))
(fma
0.5
(/ t_1 (* (* x x) (* n n)))
(fma
0.16666666666666666
(/ t_1 (* (pow x 3.0) (pow n 3.0)))
(/ t_1 (* x n)))))))
(fma
0.25
(+
(/ t_1 (* n (pow x 4.0)))
(/ t_1 (* (pow n 3.0) (pow x 4.0))))
(*
0.5
(+
(/ t_1 (* n (* x x)))
(/ t_1 (* (* n n) (pow x 3.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 = cbrt(((x + n) - n));
double t_1 = exp((-1.0 * (-log(x) / n)));
double tmp;
if (x <= -2.9019362550020532e+193) {
tmp = (x / cbrt((n * n))) / cbrt(n);
} else if (x <= 1.846802285931436e-308) {
tmp = fma(pow(t_0, 2.0), t_0, 0.0) / n;
} else if (x <= 1.2179570994719419e-236) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (x <= 4.616680033797104e-189) {
tmp = pow(sqrt((exp((log1p(x) / n)) - pow(x, (1.0 / n)))), 2.0);
} else if (x <= 808.4781327219058) {
tmp = -1.0 * ((log(x) - log1p(x)) / n);
} else {
tmp = fma(0.4583333333333333, (t_1 / ((n * n) * pow(x, 4.0))), fma(0.3333333333333333, (t_1 / (n * pow(x, 3.0))), fma(0.041666666666666664, (t_1 / (pow(x, 4.0) * pow(n, 4.0))), fma(0.5, (t_1 / ((x * x) * (n * n))), fma(0.16666666666666666, (t_1 / (pow(x, 3.0) * pow(n, 3.0))), (t_1 / (x * n))))))) - fma(0.25, ((t_1 / (n * pow(x, 4.0))) + (t_1 / (pow(n, 3.0) * pow(x, 4.0)))), (0.5 * ((t_1 / (n * (x * x))) + (t_1 / ((n * n) * pow(x, 3.0))))));
}
return tmp;
}



Bits error versus x



Bits error versus n
if x < -2.9019362550020532e193Initial program 32.8
Taylor expanded in n around inf 50.6
Taylor expanded in x around 0 56.8
Simplified56.8
Applied egg-rr53.0
if -2.9019362550020532e193 < x < 1.846802285931436e-308Initial program 61.7
Taylor expanded in n around inf 61.7
Taylor expanded in x around 0 61.7
Simplified61.7
Applied egg-rr61.7
Applied egg-rr61.7
if 1.846802285931436e-308 < x < 1.21795709947194186e-236Initial program 40.8
Taylor expanded in n around inf 20.0
if 1.21795709947194186e-236 < x < 4.6166800337971042e-189Initial program 43.2
Applied egg-rr43.2
if 4.6166800337971042e-189 < x < 808.478132721905808Initial program 51.1
Taylor expanded in n around -inf 9.7
Simplified9.7
if 808.478132721905808 < x Initial program 20.7
Taylor expanded in x around inf 17.4
Simplified17.4
Final simplification17.8
herbie shell --seed 2022127
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))