Strange behavior of NSum on 4.0
- To: mathgroup at smc.vnet.net
- Subject: [mg28045] Strange behavior of NSum on 4.0
- From: Ken Kikuchi <kikuchi at neti.com>
- Date: Thu, 29 Mar 2001 03:24:11 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
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
- Follow-Ups:
- Re: Strange behavior of NSum on 4.0
- From: Tomas Garza <tgarza01@prodigy.net.mx>
- Re: Strange behavior of NSum on 4.0