(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(FPCore (x n) :precision binary64 (if (<= x 6906.254529779961) (/ (log (/ (+ x 1.0) x)) n) (/ (exp (/ (log x) n)) (* x 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 (x <= 6906.254529779961) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((log(x) / n)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6906.254529779961d0) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = exp((log(x) / n)) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
public static double code(double x, double n) {
double tmp;
if (x <= 6906.254529779961) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log(x) / n)) / (x * n);
}
return tmp;
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
def code(x, n): tmp = 0 if x <= 6906.254529779961: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((math.log(x) / n)) / (x * n) return tmp
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function code(x, n) tmp = 0.0 if (x <= 6906.254529779961) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(log(x) / n)) / Float64(x * n)); end return tmp end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6906.254529779961) tmp = log(((x + 1.0) / x)) / n; else tmp = exp((log(x) / n)) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, n_] := If[LessEqual[x, 6906.254529779961], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;x \leq 6906.254529779961:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\
\end{array}



Bits error versus x



Bits error versus n
Results
if x < 6906.2545297799606Initial program 47.0
Taylor expanded in n around inf 14.0
Simplified14.0
Applied egg-rr14.0
if 6906.2545297799606 < x Initial program 20.1
Taylor expanded in x around inf 1.4
Simplified1.4
Final simplification7.1
herbie shell --seed 2022153
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))