{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\begin{array}{l}
\mathbf{if}\;n \le -0.016233638685546038:\\
\;\;\;\;\left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} + \sqrt{{x}^{\left(\frac{1}{n}\right)}}\right) \cdot \mathsf{fma}\left(-0.25, \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left({x}^{2} \cdot n\right)\right)} + \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}, \frac{\frac{0.5}{n}}{x}\right)\\
\mathbf{elif}\;n \le 6336551.06249121483:\\
\;\;\;\;\left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} + \sqrt{{x}^{\left(\frac{1}{n}\right)}}\right) \cdot e^{\log \left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} - \sqrt{{x}^{\left(\frac{1}{n}\right)}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{1}{x \cdot n}, -\mathsf{fma}\left(0.5, \frac{1}{{x}^{2} \cdot n}, 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)\right)\\
\end{array}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 temp;
if ((n <= -0.016233638685546038)) {
temp = ((sqrt(pow((x + 1.0), (1.0 / n))) + sqrt(pow(x, (1.0 / n)))) * fma(-0.25, ((1.0 / log1p(expm1((pow(x, 2.0) * n)))) + (log((1.0 / x)) / (x * pow(n, 2.0)))), ((0.5 / n) / x)));
} else {
double temp_1;
if ((n <= 6336551.062491215)) {
temp_1 = ((sqrt(pow((x + 1.0), (1.0 / n))) + sqrt(pow(x, (1.0 / n)))) * exp(log((sqrt(pow((x + 1.0), (1.0 / n))) - sqrt(pow(x, (1.0 / n)))))));
} else {
temp_1 = fma(1.0, (1.0 / (x * n)), -fma(0.5, (1.0 / (pow(x, 2.0) * n)), (1.0 * (log((1.0 / x)) / (x * pow(n, 2.0))))));
}
temp = temp_1;
}
return temp;
}



Bits error versus x



Bits error versus n
Results
if n < -0.016233638685546038Initial program 44.8
rmApplied add-sqr-sqrt44.9
Applied add-sqr-sqrt44.8
Applied difference-of-squares44.8
Taylor expanded around inf 33.8
Simplified33.2
rmApplied log1p-expm1-u33.2
if -0.016233638685546038 < n < 6336551.062491215Initial program 8.1
rmApplied add-sqr-sqrt8.1
Applied add-sqr-sqrt8.1
Applied difference-of-squares8.1
rmApplied add-exp-log8.1
if 6336551.062491215 < n Initial program 44.7
Taylor expanded around inf 31.6
Simplified31.6
Final simplification22.3
herbie shell --seed 2020057 +o rules:numerics
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))