Re: Strange behavior of NSum on 4.0
- To: mathgroup at smc.vnet.net
- Subject: [mg28064] Re: Strange behavior of NSum on 4.0
- From: "Sebastien de Menten" <sdementen at hotmail.com>
- Date: Fri, 30 Mar 2001 04:12:18 -0500 (EST)
- References: <99uruh$5vv@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, NSum[] is very different of N[Sum[]]. NSum will give an approximation of the sum by an integral or by a fit (in the help page : "NSum uses either the EulerMaclaurin (Integrate) or Wynn epsilon (Fit) method.") So, it supposes that the arguments can be evaluated at fractional points and not only integers. But trying to evaluate a[[41/2]] make no sense while evaluating f[41/2] makes sense (in general). Even if the Help says that N[Sum[]] calls NSum, I think they must be wrong. I hope it helps. Seb "Ken Kikuchi" <kikuchi at neti.com> wrote in message news:99uruh$5vv at smc.vnet.net... > I encountered a strange behavior with NSum on Mathematica 4.0 on Mac. > The following is a simplified example about sum of 1 to 25. > > In[1]:= a = Range[25] > Out[1]= > {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, > 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25} > > In[2]:= NSum[a[[i]], {i, 25}] > > I expected the result as 325 but received the following strange error > messages. > > Part::pspec : > Part specification 41/2 is neither an integer nor a list of > integers. > ... > NIntegrate::inum : > Integrand <<1>>[[41/2]] is not numerical at {1}={41/2}." > > However, the same code works fine up to 24. > In[23]:= NSum[a[[i]], {i, 24}] > Out[23]= 300. > > It works fine if not using Part. > In[3]:= NSum[i, {i, 25}] > Out[3]= 325. > > But Part works fine with N while manual noted -- N[Sum[...]] calls NSum. > In[4]:= N[Sum[a[[i]], {i, 25}]] > Out[4]= 325. > > And Sum works too. > In[5]:= Sum[a[[i]], {i, 25}] > Out[5]= 325 > > My version is, > In[6]:= $Version > Out[6]= "4.0 for Power Macintosh (July 26, 1999)" > > I am not sure it's only my environmental problem or my incorrect usage. > Could anyone help me? > > Many thanks, > Ken > >