(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 (exp (/ (log x) n)))
(t_1
(fma (/ t_0 (* x x)) (+ (/ 0.5 (* n n)) (/ -0.5 n)) (/ t_0 (* n x))))
(t_2 (sqrt (pow x (/ 1.0 n))))
(t_3 (fma (- t_2) t_2 (exp (/ (log1p x) n)))))
(if (<= (/ 1.0 n) -1e+158)
t_3
(if (<= (/ 1.0 n) -1.9e-23)
t_1
(if (<= (/ 1.0 n) 4e-88)
(+
(/ (log (/ (+ 1.0 x) x)) n)
(* (/ 0.5 n) (- (/ (pow (log1p x) 2.0) n) (/ (pow (log x) 2.0) n))))
(if (<= (/ 1.0 n) 0.0002) t_1 t_3))))))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 = exp((log(x) / n));
double t_1 = fma((t_0 / (x * x)), ((0.5 / (n * n)) + (-0.5 / n)), (t_0 / (n * x)));
double t_2 = sqrt(pow(x, (1.0 / n)));
double t_3 = fma(-t_2, t_2, exp((log1p(x) / n)));
double tmp;
if ((1.0 / n) <= -1e+158) {
tmp = t_3;
} else if ((1.0 / n) <= -1.9e-23) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-88) {
tmp = (log(((1.0 + x) / x)) / n) + ((0.5 / n) * ((pow(log1p(x), 2.0) / n) - (pow(log(x), 2.0) / n)));
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else {
tmp = t_3;
}
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) t_0 = exp(Float64(log(x) / n)) t_1 = fma(Float64(t_0 / Float64(x * x)), Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n)), Float64(t_0 / Float64(n * x))) t_2 = sqrt((x ^ Float64(1.0 / n))) t_3 = fma(Float64(-t_2), t_2, exp(Float64(log1p(x) / n))) tmp = 0.0 if (Float64(1.0 / n) <= -1e+158) tmp = t_3; elseif (Float64(1.0 / n) <= -1.9e-23) tmp = t_1; elseif (Float64(1.0 / n) <= 4e-88) tmp = Float64(Float64(log(Float64(Float64(1.0 + x) / x)) / n) + Float64(Float64(0.5 / n) * Float64(Float64((log1p(x) ^ 2.0) / n) - Float64((log(x) ^ 2.0) / n)))); elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; else tmp = t_3; end return 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_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[((-t$95$2) * t$95$2 + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+158], t$95$3, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.9e-23], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-88], N[(N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] + N[(N[(0.5 / n), $MachinePrecision] * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] - N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, t$95$3]]]]]]]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
t_1 := \mathsf{fma}\left(\frac{t_0}{x \cdot x}, \frac{0.5}{n \cdot n} + \frac{-0.5}{n}, \frac{t_0}{n \cdot x}\right)\\
t_2 := \sqrt{{x}^{\left(\frac{1}{n}\right)}}\\
t_3 := \mathsf{fma}\left(-t_2, t_2, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+158}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;\frac{1}{n} \leq -1.9 \cdot 10^{-23}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-88}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n} + \frac{0.5}{n} \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \frac{{\log x}^{2}}{n}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
if (/.f64 1 n) < -9.99999999999999953e157 or 2.0000000000000001e-4 < (/.f64 1 n) Initial program 3.0
Applied egg-rr0.9
if -9.99999999999999953e157 < (/.f64 1 n) < -1.90000000000000006e-23 or 3.99999999999999974e-88 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 28.5
Taylor expanded in x around inf 20.2
Simplified20.2
if -1.90000000000000006e-23 < (/.f64 1 n) < 3.99999999999999974e-88Initial program 42.7
Taylor expanded in n around inf 12.3
Simplified12.3
Applied egg-rr12.2
Final simplification11.9
herbie shell --seed 2022210
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))