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



Bits error versus x



Bits error versus n
Results
if (/.f64 1 n) < -1.9573488753029086e-11Initial program 2.1
rmApplied add-log-exp_binary642.7
Applied add-log-exp_binary642.6
Applied diff-log_binary642.6
Simplified2.6
if -1.9573488753029086e-11 < (/.f64 1 n) < 4.1846742778679711e-15Initial program 45.2
Taylor expanded around inf 32.8
Simplified32.6
if 4.1846742778679711e-15 < (/.f64 1 n) Initial program 8.8
rmApplied sqr-pow_binary648.9
Simplified8.9
Simplified8.9
rmApplied pow-prod-down_binary6410.3
Final simplification24.3
herbie shell --seed 2020260
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))