From: gopher on
In the following, A and Expand[A] give different answers after when
summed (a finite geometric series.) The result of summing A is clearly
wrong, since it is independent of the parameters r and s.

Abhishek

In[44]:= A = x^(i - n) (x^(i - n) (1 - r x^n) - s);
A == Expand[A] // Simplify

Out[45]= True

In[46]:= Sum[A, {i, 0, n - 1}]

Out[46]= (x^(-2 n) (-1 + x^(2 n)))/(-1 + x^2)

In[47]:= Sum[Expand[A], {i, 0, n - 1}] // FullSimplify

Out[47]= -((
x^(-2 n) (-1 + x^n) (-1 + x^n (-1 + r + s + s x + r x^n)))/(-1 + x^2)
)

From: Bob Hanlon on

Works fine on my system

$Version

7.0 for Mac OS X x86 (64-bit) (February 19, 2009)

A = x^(i - n) (x^(i - n) (1 - r x^n) - s);

A == Expand[A] // Simplify

True

Sum[A, {i, 0, n - 1}]

-(((x^n - 1)*(r*x^(2*n) + r*x^n + s*x^(n + 1) +
s*x^n - x^n - 1))/(x^(2*n)*(x^2 - 1)))

Sum[Expand[A], {i, 0, n - 1}] // FullSimplify

-(((x^n - 1)*(x^n*(r*x^n + r + s*x + s - 1) - 1))/
(x^(2*n)*(x^2 - 1)))

% == %% // Simplify

True


Bob Hanlon

---- gopher <gophergoon(a)gmail.com> wrote:

=============
In the following, A and Expand[A] give different answers after when
summed (a finite geometric series.) The result of summing A is clearly
wrong, since it is independent of the parameters r and s.

Abhishek

In[44]:= A = x^(i - n) (x^(i - n) (1 - r x^n) - s);
A == Expand[A] // Simplify

Out[45]= True

In[46]:= Sum[A, {i, 0, n - 1}]

Out[46]= (x^(-2 n) (-1 + x^(2 n)))/(-1 + x^2)

In[47]:= Sum[Expand[A], {i, 0, n - 1}] // FullSimplify

Out[47]= -((
x^(-2 n) (-1 + x^n) (-1 + x^n (-1 + r + s + s x + r x^n)))/(-1 + x^2)
)



From: Sjoerd C. de Vries on
Abhishek,

I don't seem to be able to reproduce your bug. For Sum A I get:

-((x^(-2 n) (-1 + x^n) (-1 - x^n + r x^n + s x^n + r x^(2 n) +
s x^(1 + n)))/(-1 + x^2))

which depends on r and s.
Same result for Expand[A].

In[6]:= $Version

Out[6]= "7.0 for Microsoft Windows (32-bit) (February 18, 2009)"

Cheers -- Sjoerd

On Apr 13, 5:01 am, gopher <gopherg...(a)gmail.com> wrote:
> In the following, A and Expand[A] give different answers after when
> summed (a finite geometric series.) The result of summing A is clearly
> wrong, since it is independent of the parameters r and s.
>
> Abhishek
>
> In[44]:= A = x^(i - n) (x^(i - n) (1 - r x^n) - s);
> A == Expand[A] // Simplify
>
> Out[45]= True
>
> In[46]:= Sum[A, {i, 0, n - 1}]
>
> Out[46]= (x^(-2 n) (-1 + x^(2 n)))/(-1 + x^2)
>
> In[47]:= Sum[Expand[A], {i, 0, n - 1}] // FullSimplify
>
> Out[47]= -((
> x^(-2 n) (-1 + x^n) (-1 + x^n (-1 + r + s + s x + r x^n)))/(-1 + x^2)
> )


From: Erik Max Francis on
gopher wrote:
> In the following, A and Expand[A] give different answers after when
> summed (a finite geometric series.) The result of summing A is clearly
> wrong, since it is independent of the parameters r and s.
>
> Abhishek
>
> In[44]:= A = x^(i - n) (x^(i - n) (1 - r x^n) - s);
> A == Expand[A] // Simplify
>
> Out[45]= True
>
> In[46]:= Sum[A, {i, 0, n - 1}]
>
> Out[46]= (x^(-2 n) (-1 + x^(2 n)))/(-1 + x^2)
>
> In[47]:= Sum[Expand[A], {i, 0, n - 1}] // FullSimplify
>
> Out[47]= -((
> x^(-2 n) (-1 + x^n) (-1 + x^n (-1 + r + s + s x + r x^n)))/(-1 + x^2)
> )

They're both equal. FullSimplify on the first sum results in the same
thing:

In[17]:= Sum[A, {i, 0, n - 1}] // FullSimplify

Out[17]= -((
x^(-2 n) (-1 + x^n) (-1 + x^n (-1 + r + s + s x + r x^n)))/(-1 + x^2)
)

By default Mathematica doesn't do a FullSimplify, so you end up with
different, but equal answers. If you do FullSimplify on both, then the
answers are not only equal, but identical.

--
Erik Max Francis && max(a)alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
There is no fate that cannot be surmounted by scorn.
-- Albert Camus

From: Tony Harker on
What version are you using? 7.0 for Microsoft Windows (32-bit) (February 18,
2009) gives identical, correct, results for both.

Tony Harker

]-> -----Original Message-----
]-> From: gopher [mailto:gophergoon(a)gmail.com]
]-> Sent: 13 April 2010 04:04
]-> To: mathgroup(a)smc.vnet.net
]-> Subject: Bug in Sum?
]->
]-> In the following, A and Expand[A] give different answers after when
]-> summed (a finite geometric series.) The result of summing A
]-> is clearly
]-> wrong, since it is independent of the parameters r and s.
]->
]-> Abhishek
]->
]-> In[44]:= A = x^(i - n) (x^(i - n) (1 - r x^n) - s);
]-> A == Expand[A] // Simplify
]->
]-> Out[45]= True
]->
]-> In[46]:= Sum[A, {i, 0, n - 1}]
]->
]-> Out[46]= (x^(-2 n) (-1 + x^(2 n)))/(-1 + x^2)
]->
]-> In[47]:= Sum[Expand[A], {i, 0, n - 1}] // FullSimplify
]->
]-> Out[47]= -((
]-> x^(-2 n) (-1 + x^n) (-1 + x^n (-1 + r + s + s x + r
]-> x^n)))/(-1 + x^2)
]-> )
]->
]->