Re: Can it be done - easily?
- To: mathgroup at smc.vnet.net
- Subject: [mg13242] Re: Can it be done - easily?
- From: Seth Chandler <SChandler at Central.UH.Edu>
- Date: Fri, 17 Jul 1998 03:17:39 -0400
- Organization: University of Houston
- References: <6od25q$hn9@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I'm not sure whether the result qualifies as "simple", but Mathematica can quickly compute a closed form formula that appears to do what you want. In[13]:= (culhane[x_,{ymin_,ymax_,yinc_}]=FullSimplify[Sum[x/y,{y,ymin,ymax,yinc}]])// InputForm Out[13]//InputForm= (x*(-PolyGamma[0, ymin/yinc] + PolyGamma[0, 1 + ymin/yinc + Floor[(ymax - ymin)/yinc]]))/yinc In[14]:= culhane[10000,{100,1000,100}]//InputForm Out[14]//InputForm= 36905/126 In[15]:= N[%] Out[15]= 292.897 Seth J. Chandler Associate Professor of Law University of Houston Law Center Barry Culhane wrote: > Myself and two workmates are software developers. One guy wanted a > formula to calculate a result for the following equation... > Z = sum of X/Y where X is a fixed number, and Y ranges from A-B in > fixed steps... > i.e... X=10000 ; Y=100,200,300...1000 > i.e... Z= 10000/100 + 10000/200 + ... 10000/1000 = 292.896 > > He and I tried to figure out a simple formula to calculate it, but > couldn't. The third guy said it was *not* *possible* to derive a > formula - we think he's wrong, but can't prove it. MathCad can solve > it in the blink of an eye, even if the value of Y ranges from 1 to 1e6 > in steps of 1 !!! > > Can anyone come up with a simple formula to give a reasonably accurate > result? It is too slow to actually divide X by Y for each value of Y > as there may be 1000 or even 100,000 values of Y. > > Thanks in advance... > > Barry Culhane > > Schaffner Ltd, Limerick, IRELAND