Re: NSum bug or am I doing something wrong?
- To: mathgroup at smc.vnet.net
- Subject: [mg93904] Re: NSum bug or am I doing something wrong?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 28 Nov 2008 05:07:59 -0500 (EST)
On 11/27/08 at 5:33 AM, ebpr08 at gmail.com (Ebpr Preb) wrote:
>I'm getting imaginary answers for simple NSums of rational numbers.
>The example below produces the issue in Mathematica 7:
>NSum[(-1)^(k + 1)*(.2)^k, {k, 1, 32}]
>gives me the result:
>0.166667 + 1.1972*10^-44 I
>When I switch to Sum the problem disappears.
>Any hint?
Use Chop, e.g.
In[5]:= Chop@NSum[(-1)^(k + 1)*(.2)^k, {k, 1, 32}]
Out[5]= 0.166667