Bug introduced in 10.1.0 and fixed in 10.4.0
Coefficient[
Sum[x^k, {k, 0, 1000}]
Sum[x^k, {k, 0, 1000, 2}]
Sum[x^k, {k, 0, 1000, 5}]
Sum[x^k, {k, 0, 1000, 10}]
Sum[x^k, {k, 0, 1000, 20}]
Sum[x^k, {k, 0, 1000, 50}]
Sum[x^k, {k, 0, 1000, 100}] // Expand, x, 1000] // AbsoluteTiming
{0.032555, 11583833929}
That is why I love Mathematica. Now I just tack on another polynomial...
Coefficient[
Sum[x^k, {k, 0, 1000}]
Sum[x^k, {k, 0, 1000, 2}]
Sum[x^k, {k, 0, 1000, 5}]
Sum[x^k, {k, 0, 1000, 10}]
Sum[x^k, {k, 0, 1000, 20}]
Sum[x^k, {k, 0, 1000, 50}]
Sum[x^k, {k, 0, 1000, 100}]
Sum[x^k,{k,0,1000,200}] // Expand, x, 1000] // AbsoluteTiming
{0.039276, -190969169941}
How do I get a negative coefficient for x^1000 when all those polys have positive coefficients? Where did I go wrong?
I am afraid that in light of Bob's calculations which I know are correct I am going to have to say that this is a bug in 10.1 when running on Linux Mint 17.1 Rebecca.
If I do it this way:
Coefficient[
Series[Sum[x^k, {k, 0, 1000}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 2}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 5}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 10}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 20}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 50}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 100}], {x, 0, 1000}], x, 1000] // AbsoluteTiming
{0.009989, 234896541}
Coefficient[
Series[Sum[x^k, {k, 0, 1000}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 2}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 5}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 10}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 20}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 50}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 100}], {x, 0, 1000}]
Series[Sum[x^k, {k, 0, 1000, 200}], {x, 0, 1000}] , x, 1000] // AbsoluteTiming
{0.007549, 321335886}
we get the correct answer, this is probably due to fact that the series command truncates each poly not allowing intermediate calculations to trigger the anomaly that happens when large polys are multiplied in 10.1 on this OS.
234896541
for the first coefficient and321335886
for the second. By the way, the use ofExpand
is not necessary to get the coefficients. $\endgroup$Series
are becauseSeries
caches its computations. When you repeat them, it just looks up the previous result. (Correct answer aside). $\endgroup$