MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can it be done - easily?

Z[X_, {Y_Symbol, Ymin_, Ymax_, Ystep_:1}] := 
	Evaluate[Sum[X/Y, {Y, Ymin, Ymax, Ystep}]];

Z[X, {Y, Ymin, Ymax, Ystep}]

(X*(PolyGamma[0, Ymin/Ystep + Floor[(Ymax - Ymin)/Ystep] + 1] -
PolyGamma[0, Ymin/Ystep]))/Ystep

"PolyGamma[z] gives the digamma function psi(z). PolyGamma[n, z] gives
the \ nth derivative of the digamma function." Attributes[PolyGamma] =
{Listable, NHoldFirst, Protected, ReadProtected}

Sum[10000/Y, {Y, 100, 1000, 100}]


Z[10000, {Y, 100, 1000, 100}]


Z[10000, {Y, 1., 1.*^6, 1.}]


Note: speed requires use of real rather than integer values for

Bob Hanlon

In a message dated 7/13/98 2:54:54 PM, barryc at 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.

  • Prev by Date: Re: "UnFullForm"ing an Expression?
  • Next by Date: Re: Problems with numerical precision
  • Previous by thread: Re: Can it be done - easily?
  • Next by thread: Re: Can it be done - easily?