MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NSum bug or am I doing something wrong?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93888] Re: [mg93869] NSum bug or am I doing something wrong?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 28 Nov 2008 05:05:04 -0500 (EST)
  • Reply-to: hanlonr at cox.net

It is numerical noise, just use Chop.

NSum[(-1)^(k + 1)*(0.2)^k, {k, 1, 32}]

0.166667 +  1.1972*^-44*I

Sum[(-1)^(k + 1)*(0.2)^k, {k, 1, 32}]

0.166667

Sum[(-1)^(k + 1)*(2/10)^k, {k, 1, 32}] // N

0.166667

NSum[(-1)^(k + 1)*(.2)^k, {k, 1, 32}] // Chop

0.166667


Bob Hanlon
---- Ebpr Preb <ebpr08 at gmail.com> wrote: 

=============
Hi,

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?

Thanks so much.

ebpr



--

Bob Hanlon



  • Prev by Date: Re: Very Long Time
  • Next by Date: RE: NSum bug or am I doing something wrong?
  • Previous by thread: Re: NSum bug or am I doing something wrong?
  • Next by thread: RE: NSum bug or am I doing something wrong?