MathGroup Archive 2009

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

Search the Archive

Re: Issue with Sum Version7

  • To: mathgroup at
  • Subject: [mg95637] Re: Issue with Sum Version7
  • From: Bill Rowe <readnews at>
  • Date: Fri, 23 Jan 2009 05:08:27 -0500 (EST)

On 1/22/09 at 7:05 AM, bghekaya at wrote:

>Anyone seen this:

>In[120]:= Sum[i, {i, 0, 99999, .1}]

>Out[120]= 4.99991*10^10

>In[121]:= Sum[i, {i, 0, 100000, .1}]

>Out[121]= Sum[i, {i, 0, 100000, 0.1}]

>On Mac OS X 10.5.6

I get the same result. But this result is easily avoided by either

In[3]:= NSum[i, {i, 0, 100000, .1}]

Out[3]= 5.00001*10^10


In[4]:= Sum[i, {i, 0, 100000, 1/10}]

Out[4]= 50000050000

The general rule in Mathematica is when working with machine
precision numbers you should use the functions that start with N.

The key advantage of Sum over NSum is being able to return
symbolic answers for simple problems. Note

In[7]:= Sum[n, {n, 0, k, a}]

Out[7]= (k (a+k))/(2 a)

returns nearly instantly, much faster than doing the explicit sum.


In[1]:= Sum[n, {n, 0, 100000, 1/10}] // Timing

Out[1]= {0.135397,50000050000}

In[2]:= Sum[n, {n, 0, k, a}] /. {a -> 1/10, k -> 100000} // Timing

Out[2]= {0.018729,50000050000}

Of course none of this changes the fact there appears to be a
problem with Sum.

  • Prev by Date: Extracting Graphics3D from Plots
  • Next by Date: A question about Mathematica
  • Previous by thread: Re: Issue with Sum Version7
  • Next by thread: Tab and Cursor Arrow Key Bindings