Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [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

> 

> 




  • Prev by Date: Re: NSum bug or am I doing something wrong?
  • Next by Date: Re: Mathematica 7: PieChart: opacity of a sector
  • Previous by thread: Re: NSum bug or am I doing something wrong?
  • Next by thread: Re: NSum bug or am I doing something wrong?