(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 (log x) 2.0))
(t_1 (/ (log x) n))
(t_2 (log (+ x 1.0)))
(t_3 (pow (log x) 3.0)))
(if (<= x 2.7e-246)
(+
(/ x n)
(-
(* (/ t_3 (pow n 3.0)) -0.16666666666666666)
(fma 0.5 (/ t_0 (* n n)) t_1)))
(if (<= x 1.7e-225)
(- (pow (+ x 1.0) (/ 1.0 n)) (expm1 (log1p (pow x (/ 1.0 n)))))
(if (<= x 2.1e-13)
(+
(+
(* 0.5 (/ (pow t_2 2.0) (pow n 2.0)))
(+
(* 0.041666666666666664 (/ (pow t_2 4.0) (pow n 4.0)))
(+
(/
(+
(* t_3 -0.16666666666666666)
(* 0.16666666666666666 (pow t_2 3.0)))
(pow n 3.0))
(/ (- t_2 (log x)) n))))
(+
(* (/ t_0 (pow n 2.0)) -0.5)
(* (/ (pow (log x) 4.0) (pow n 4.0)) -0.041666666666666664)))
(/ (exp t_1) (* 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 t_0 = pow(log(x), 2.0);
double t_1 = log(x) / n;
double t_2 = log((x + 1.0));
double t_3 = pow(log(x), 3.0);
double tmp;
if (x <= 2.7e-246) {
tmp = (x / n) + (((t_3 / pow(n, 3.0)) * -0.16666666666666666) - fma(0.5, (t_0 / (n * n)), t_1));
} else if (x <= 1.7e-225) {
tmp = pow((x + 1.0), (1.0 / n)) - expm1(log1p(pow(x, (1.0 / n))));
} else if (x <= 2.1e-13) {
tmp = ((0.5 * (pow(t_2, 2.0) / pow(n, 2.0))) + ((0.041666666666666664 * (pow(t_2, 4.0) / pow(n, 4.0))) + ((((t_3 * -0.16666666666666666) + (0.16666666666666666 * pow(t_2, 3.0))) / pow(n, 3.0)) + ((t_2 - log(x)) / n)))) + (((t_0 / pow(n, 2.0)) * -0.5) + ((pow(log(x), 4.0) / pow(n, 4.0)) * -0.041666666666666664));
} else {
tmp = exp(t_1) / (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) t_0 = log(x) ^ 2.0 t_1 = Float64(log(x) / n) t_2 = log(Float64(x + 1.0)) t_3 = log(x) ^ 3.0 tmp = 0.0 if (x <= 2.7e-246) tmp = Float64(Float64(x / n) + Float64(Float64(Float64(t_3 / (n ^ 3.0)) * -0.16666666666666666) - fma(0.5, Float64(t_0 / Float64(n * n)), t_1))); elseif (x <= 1.7e-225) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - expm1(log1p((x ^ Float64(1.0 / n))))); elseif (x <= 2.1e-13) tmp = Float64(Float64(Float64(0.5 * Float64((t_2 ^ 2.0) / (n ^ 2.0))) + Float64(Float64(0.041666666666666664 * Float64((t_2 ^ 4.0) / (n ^ 4.0))) + Float64(Float64(Float64(Float64(t_3 * -0.16666666666666666) + Float64(0.16666666666666666 * (t_2 ^ 3.0))) / (n ^ 3.0)) + Float64(Float64(t_2 - log(x)) / n)))) + Float64(Float64(Float64(t_0 / (n ^ 2.0)) * -0.5) + Float64(Float64((log(x) ^ 4.0) / (n ^ 4.0)) * -0.041666666666666664))); else tmp = Float64(exp(t_1) / Float64(x * n)); 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[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]}, If[LessEqual[x, 2.7e-246], N[(N[(x / n), $MachinePrecision] + N[(N[(N[(t$95$3 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - N[(0.5 * N[(t$95$0 / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.7e-225], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(Exp[N[Log[1 + N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1e-13], N[(N[(N[(0.5 * N[(N[Power[t$95$2, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.041666666666666664 * N[(N[Power[t$95$2, 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(t$95$3 * -0.16666666666666666), $MachinePrecision] + N[(0.16666666666666666 * N[Power[t$95$2, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$2 - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] + N[(N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[t$95$1], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := {\log x}^{2}\\
t_1 := \frac{\log x}{n}\\
t_2 := \log \left(x + 1\right)\\
t_3 := {\log x}^{3}\\
\mathbf{if}\;x \leq 2.7 \cdot 10^{-246}:\\
\;\;\;\;\frac{x}{n} + \left(\frac{t_3}{{n}^{3}} \cdot -0.16666666666666666 - \mathsf{fma}\left(0.5, \frac{t_0}{n \cdot n}, t_1\right)\right)\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-225}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{1}{n}\right)}\right)\right)\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-13}:\\
\;\;\;\;\left(0.5 \cdot \frac{{t_2}^{2}}{{n}^{2}} + \left(0.041666666666666664 \cdot \frac{{t_2}^{4}}{{n}^{4}} + \left(\frac{t_3 \cdot -0.16666666666666666 + 0.16666666666666666 \cdot {t_2}^{3}}{{n}^{3}} + \frac{t_2 - \log x}{n}\right)\right)\right) + \left(\frac{t_0}{{n}^{2}} \cdot -0.5 + \frac{{\log x}^{4}}{{n}^{4}} \cdot -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{t_1}}{x \cdot n}\\
\end{array}
if x < 2.6999999999999999e-246Initial program 40.8
Taylor expanded in n around inf 19.9
Simplified19.9
Taylor expanded in x around 0 19.9
Simplified19.9
if 2.6999999999999999e-246 < x < 1.7e-225Initial program 43.1
Applied egg-rr43.1
if 1.7e-225 < x < 2.09999999999999989e-13Initial program 49.0
Taylor expanded in n around -inf 11.8
if 2.09999999999999989e-13 < x Initial program 21.5
Taylor expanded in x around inf 3.2
Simplified3.2
Final simplification9.0
herbie shell --seed 2022202
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))