Re: Can it be done - easily?
- To: mathgroup at smc.vnet.net
- Subject: [mg13322] Re: Can it be done - easily?
- From: Hans Staugaard <hans.staugaard_NO_SPAM_ at _NO_SPAM_get2net.dk>
- Date: Mon, 20 Jul 1998 02:49:43 -0400
- Organization: Get2Net Internet Kunde
- References: <6od25q$hn9@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Barry Culhane skrev:
>
> 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
Here's a function that should do the job
Z[X_,YStart_,YStop_,YStep_]:=
X(PolyGamma[1+YStop/YStep]-PolyGamma[YStart/YStep])/YStep
e.g.
> fixed steps...
> i.e... X=10000 ; Y=100,200,300...1000
> i.e... Z= 10000/100 + 10000/200 + ... 10000/1000 = 292.896
>
translates to
Z[10000,100,1000,100]
36905
which yields Z = ----- ~ 292.897
126