# Power series expansion

I am asking Mathematica for the first 5 terms in a power series expansion like this:

nn = 5; a = Sum[Binomial[n!, 2] x^n/n!, {n, 0, nn}]; Series[Log[a], {x, 0, nn}]


If I ask for the first 4 terms with the identical code except $nn=4$, I get a different answer. I do not understand why it is different. Which one is correct?

The question of the OP is equivalent to ask if the two following expressions are equal :

and

The InputForm of the first expression is :

Log[SeriesData[x, 0, {1/2, 5/2, 23/2}, 2, 6, 1]]


Once evaluated, it gives :

The InputForm of the secondexpression is :

Log[SeriesData[x, 0, {1/2, 5/2, 23/2, 119/2}, 2, 6, 1]]


Once evaluated, it gives :

In the general case, ie if there were something else than a Log, it is normal.
Concerning the Log, let's try to evaluate the symbolic form :

(The InputForm is SeriesData[x, 0, { n2, n3, n4, n5}, 2, 6, 1] )

It gives :

We see that the coefficient of x^3 depends on n5.

It seems also normal that the two expressions are different, assuming there is no error in the symbolic evaluation of Log[n2 x^2 + n3 x^3 ...+ O[x]^6].

update

One can verify thaht there's no error in the evaluation of : Log[n2 x^2 + n3 x^3 ...+ O[x]^6]

The expression :

(InputForm : expr[x_] = Log[n2 x^2 + n3 x^3 + n4 x^4 + n5 x^5] - Normal[Log[ n2 x^2 + n3 x^3 + n4 x^4 + n5 x^5 + SeriesData[ x, 0, {}, 2, 6, 1]]])

should be O[x^4]

That is true : Limit[expr[x] / x^4, x -> 0]gives :

-((n3^4 - 4 n2 n3^2 n4 + 2 n2^2 n4^2 + 4 n2^2 n3 n5)/(4 n2^4))

which is bounded.

Here's the problem, heuristically. (I'll leave it to someone who can work this out in detail as to how exactly this works mathematically, or perhaps I'll figure it out later.) The problem is that the logarithm brings down the exponent, and so in order to get all terms of degree 4, say, you need to include in your truncated series all terms out to much higher order than 4:

nn = 4;
a = Sum[Binomial[n!, 2] x^n/n!, {n, 0, nn^2}]; Series[Log[a], {x, 0, nn}]
nn = 5;
a = Sum[Binomial[n!, 2] x^n/n!, {n, 0, nn^2}]; Series[Log[a], {x, 0, nn}]


yields