It's a bit tricky and I'm not certain I have all the issues correct. Has to do with when and where the approximate numbers are computed. The first one substituted bignums of high precision into the formula for g[x]
. The second, because it has that extra layer, fools NSum
into believing it must treat the function as a "black box", and it substitutes the exact integers before numericizing. For reasons not clear to me, it is faster to do this and numericize the resulting expression after the fact (even with evaluating the exact roots). Also there could be differences in how many terms get used based on the use, or not, of the explicit form of the function.
I think this next example more or less captures what is happening.
g1[x_] := N[(x^(1/x) - 1), 10000];
g2[x_] := With[{nx = N[x, 10000]}, (nx^(1/nx) - 1)]
m = 1000;
vals = Range[m];
ClearSystemCache["Numeric"];
Timing[res1 = Map[g1, vals];]
ClearSystemCache["Numeric"];
Timing[res2 = Map[g2, vals];]
(* Out[363]= {2.019356, Null}
Out[365]= {5.185261, Null} *)