\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\]
↓
\[\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\\
t_2 := {x}^{\left(\frac{0.5}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-5}:\\
\;\;\;\;{\left(\sqrt[3]{\mathsf{fma}\left(-t_2, t_2, t_0\right) + \left(t_1 - t_0\right)}\right)}^{3}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(t_1\right)\right) - t_0\\
\end{array}
\]
(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 (pow x (/ 1.0 n)))
(t_1 (exp (/ (log1p x) n)))
(t_2 (pow x (/ 0.5 n))))
(if (<= (/ 1.0 n) -5e-5)
(pow (cbrt (+ (fma (- t_2) t_2 t_0) (- t_1 t_0))) 3.0)
(if (<= (/ 1.0 n) 0.0002)
(/ (log1p (/ 1.0 x)) n)
(- (expm1 (log1p t_1)) t_0)))))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 = pow(x, (1.0 / n));
double t_1 = exp((log1p(x) / n));
double t_2 = pow(x, (0.5 / n));
double tmp;
if ((1.0 / n) <= -5e-5) {
tmp = pow(cbrt((fma(-t_2, t_2, t_0) + (t_1 - t_0))), 3.0);
} else if ((1.0 / n) <= 0.0002) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = expm1(log1p(t_1)) - t_0;
}
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 = x ^ Float64(1.0 / n)
t_1 = exp(Float64(log1p(x) / n))
t_2 = x ^ Float64(0.5 / n)
tmp = 0.0
if (Float64(1.0 / n) <= -5e-5)
tmp = cbrt(Float64(fma(Float64(-t_2), t_2, t_0) + Float64(t_1 - t_0))) ^ 3.0;
elseif (Float64(1.0 / n) <= 0.0002)
tmp = Float64(log1p(Float64(1.0 / x)) / n);
else
tmp = Float64(expm1(log1p(t_1)) - t_0);
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[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[x, N[(0.5 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-5], N[Power[N[Power[N[(N[((-t$95$2) * t$95$2 + t$95$0), $MachinePrecision] + N[(t$95$1 - t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(Exp[N[Log[1 + t$95$1], $MachinePrecision]] - 1), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
↓
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\\
t_2 := {x}^{\left(\frac{0.5}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-5}:\\
\;\;\;\;{\left(\sqrt[3]{\mathsf{fma}\left(-t_2, t_2, t_0\right) + \left(t_1 - t_0\right)}\right)}^{3}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(t_1\right)\right) - t_0\\
\end{array}