{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -3.5513046012241705 \cdot 10^{-21}:\\
\;\;\;\;\log \left(e^{{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 9.955714559432297 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{1}{n \cdot x} - \frac{0.5}{x \cdot \left(n \cdot x\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(1 + x\right)}^{\left(\frac{2}{n}\right)} - {x}^{\left(\frac{2}{n}\right)}}{{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} + {x}^{\left(\frac{1}{n}\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
(if (<= (/ 1.0 n) -3.5513046012241705e-21)
(log (exp (- (pow (+ 1.0 x) (/ 1.0 n)) (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) 9.955714559432297e-41)
(+ (/ (log x) (* x (* n n))) (- (/ 1.0 (* n x)) (/ 0.5 (* x (* n x)))))
(/
(- (pow (+ 1.0 x) (/ 2.0 n)) (pow x (/ 2.0 n)))
(+ (pow (+ 1.0 x) (/ 1.0 n)) (pow x (/ 1.0 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 tmp;
if ((1.0 / n) <= -3.5513046012241705e-21) {
tmp = log(exp(pow((1.0 + x), (1.0 / n)) - pow(x, (1.0 / n))));
} else if ((1.0 / n) <= 9.955714559432297e-41) {
tmp = (log(x) / (x * (n * n))) + ((1.0 / (n * x)) - (0.5 / (x * (n * x))));
} else {
tmp = (pow((1.0 + x), (2.0 / n)) - pow(x, (2.0 / n))) / (pow((1.0 + x), (1.0 / n)) + pow(x, (1.0 / n)));
}
return tmp;
}



Bits error versus x



Bits error versus n
Results
if (/.f64 1 n) < -3.5513046012241705e-21Initial program 5.4
rmApplied add-log-exp_binary64_4505.7
Applied add-log-exp_binary64_4505.6
Applied diff-log_binary64_5035.6
Simplified5.6
if -3.5513046012241705e-21 < (/.f64 1 n) < 9.95571455943229747e-41Initial program 44.3
Taylor expanded around inf 32.6
Simplified32.5
if 9.95571455943229747e-41 < (/.f64 1 n) Initial program 18.4
rmApplied flip--_binary64_38918.5
Simplified18.4
Final simplification25.0
herbie shell --seed 2020299
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))