       Re: Problem with the Sum Function -- Using a Benford Distribution

• To: mathgroup at smc.vnet.net
• Subject: [mg66872] Re: [mg66838] Problem with the Sum Function -- Using a Benford Distribution
• Date: Fri, 2 Jun 2006 04:08:52 -0400 (EDT)
• References: <200606011054.GAA20562@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Thu, 1 Jun 2006, Richard Palmer wrote:

>
>
> (* define a PDF*)
> f = Log[10, 1 + 1/d]
>
>
> (* compute for various values of the parameter *)
> Table[Apply[Plus, Table[f, {d, 10 ^ h, 10 ^ (h + 1) - 1}]], {h, 0, 4}]// N
>
>
> (* the mean is well defined *)
> Table[ Apply[Plus, Table[d  Log[10, 1 + 1/d], {d, 10^h, 10^(h + 1) - 1}]] //N,
> {h, 0, 4}]
>
> (* here is a parametric formula for the mean *)
> mean =Assuming[k \[Element] Integers && k ? 0,    Sum[d Log[10, 1 + 1/d], {d,
> 10^k, 10^(k + 1) - 1}]] // FullSimplify
>
> (* the formula appears to be wrong *)
> Table[N[mean], {k, 0, 4}]
>
>
Hello Richard,

Thank you for reporting the problem with computing the logarithmic
sum above.

For examples of this type, the Sum function works by replacing
Log[expr] with expr^m, followed by differentiation, since:

===========================

In:= \$Version

Out= 5.2 for Linux (June 27, 2005)

In:= D[expr^m, m]

m
Out= expr  Log[expr]

==========================

The final answer is obtained using a limiting process to set 'm'
equal to 0. The incorrect answer in your example occurs at this
stage.

One possible workaround is to use the procedure outlined above
to compute the expression Mean1 given in Out below.

=================================

In:= s1 = Sum[d*((d + 1)^m/Log), {d, 10^k, 10^(k + 1) - 1}] -
Sum[d*(d^m/Log), {d, 10^k, 10^(k + 1) - 1}];

In:= (Mean1 = D[s1, m] /. {m ->  0}) // InputForm

Out//InputForm=
-((-Derivative[1, 0][Zeta][-1, 10^k] + Derivative[1, 0][Zeta][-1,
10^(1 + k)])/Log) + (-Derivative[1, 0][Zeta][-1, 1 + 10^k] +
Derivative[1, 0][Zeta][-1, 1 + 10^(1 + k)] + Derivative[1, 0][Zeta][0,
1 + 10^k] - Derivative[1, 0][Zeta][0, 1 + 10^(1 + k)])/Log

In:= Table[Mean1, {k, 0, 4}] // N // Chop

Out= {3.44024, 38.5898, 390.365, 3908.15, 39086.}

In:= Table[N[Plus @@ Table[d*Log[10, 1 + 1/d], {d, 10^h, 10^(h + 1) -
1}]], {h, 0, 4}]

Out= {3.44024, 38.5898, 390.365, 3908.15, 39086.}

=================================

I apologize for the inconvenience caused by this problem.

Sincerely,