Re: NSum bug or am I doing something wrong?
- To: mathgroup at smc.vnet.net
- Subject: [mg93921] Re: NSum bug or am I doing something wrong?
- From: dh <dh at metrohm.com>
- Date: Fri, 28 Nov 2008 05:11:03 -0500 (EST)
- References: <gglt0i$8j7$1@smc.vnet.net>
Hi, working with machine numbers is never accurate. Mathematica does certainly not simply add up numbers, but may be using a general algorithm. It is then not astonishing that the imaginary part of the answer is only approximately zero. You may use Chop to eliminate it. If you use Sum you do not get an imaginary part. Further, often it is better to use rational number instead of decimal ones. hope this helps, Daniel Ebpr Preb 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 > >