Re: Can it be done - easily?
- To: mathgroup at smc.vnet.net
- Subject: [mg13241] Re: [mg13211] Can it be done - easily?
- From: Robert Pratt <rpratt at math.unc.edu>
- Date: Fri, 17 Jul 1998 03:17:38 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Whether you like this or not will depend on your definition of "simple" formula. Paste the following into a notebook to view it. Note that the x can just be factored out of the sum. z[x_,a_,b_,k_]:=Sum[x/y,{y,a,b,k}] z[10000,100,1000,100] \!\(36905\/126\) N[%] 292.897 z[x,a,b,k] \!\(\(x\ \(( \(-PolyGamma[0, a\/k]\) + PolyGamma[0, 1 + a\/k + Floor[\(\(-a\) + b\)\/k]])\)\)\/k\) ?PolyGamma "PolyGamma[z] gives the digamma function psi(z). PolyGamma[n, z] gives the \ nth derivative of the digamma function." Rob Pratt Department of Mathematics The University of North Carolina at Chapel Hill CB# 3250, 331 Phillips Hall Chapel Hill, NC 27599-3250 rpratt at math.unc.edu http://www.math.unc.edu/Grads/rpratt/ On Mon, 13 Jul 1998, 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