       Re: Problem with RSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg62722] Re: Problem with RSolve
• From: Maxim <m.r at inbox.ru>
• Date: Fri, 2 Dec 2005 05:53:30 -0500 (EST)
• References: <dmlvb5\$m5j\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```I believe this is related to the bug in Sum:

In:=
Sum[k^2*Log[k], {k, n}]

Out=
-(13/18) - (23*n)/12 - (19*n^2)/12 - (7*n^3)/18 + Log[Gamma[1 + n]]
+ 2*n*Log[Gamma[1 + n]] + n^2*Log[Gamma[1 + n]] - Log[Gamma[2 + n]] -
2*n*Log[Gamma[2 + n]] - n^2*Log[Gamma[2 + n]] + Zeta/(4*Pi^2)
+ Derivative[1, 0][Zeta][-2, 2 + n]

Evidently RSolve takes this incorrect result and adds 13/18 to satisfy the
initial condition. Summation or integration often works better for the
general case:

In:=
Sum[k^p*Log[k], {k, n}] /. p -> 2

Out=
Zeta/(4*Pi^2) + Derivative[1, 0][Zeta][-2, 1 + n]

This is also the correct value for c[n]. It is easy to see where the
derivative comes from if we consider that k^p*Log[k] == D[k^p, p] and
Sum[k^p, {k, n}] == HarmonicNumber[n, -p]. Incidentally, Mathematica gets
the sign of the derivative of HarmonicNumber wrong:

In:=
D[HarmonicNumber[n, -p], p] /. p -> 2

Out=
-(Zeta/(4*Pi^2)) - Derivative[1, 0][Zeta][-2, 1 + n]

The leading term in the asymptotic expansion of Zeta[p, n] is n^(1 - p)/(p
- 1) and Derivative[1, 0][Zeta][p, n] is asymptotic to -n^(1 -
p)*Log[n]/(p - 1). Hence c[n] is asymptotic to n^3*Log[n]/3, which I
suppose also can be seen by applying the Euler-Maclaurin formula to
Sum[k^2*Log[k], {k, n}] directly.

This can also be checked numerically, but here we have another
illustration of the fact that we cannot trust Mathematica's significance
arithmetic when evaluating special functions for very large values of the
arguments, very close to singularities, etc. and especially when
evaluating derivatives:

In:=
N[Derivative[1, 0][Zeta][-2, 10^100], 100]

Out=
5.1756291918918863991247522345022089269714293900735639116077545366824429242649554860756394743197164109477252732114`100.*^305

All the digits here are incorrect.

Maxim Rytin
m.r at inbox.ru

On Thu, 1 Dec 2005 04:48:37 +0000 (UTC), Bob Hanlon <hanlonr at cox.net>
wrote:

> \$Version
>
> 5.2 for Mac OS X (June 20, 2005)
>
> Clear[a,c,n];
>
> a=0;
> a[n_Integer?Positive]:=
>     a[n]=a[n-1]+(n^2) Log[n];
>
> Table[a[n],{n,0,5}]//Simplify
>
> {0, 0, Log, Log, 9*Log + 16*Log + Log,
>   9*Log + 16*Log + 25*Log + Log}
>
> RSolve gives a wrong result
>
> soln=c[n]/.
>     (RSolve[{c[n]==c[n-1]+(n^2) Log[n],
>               c==0},c[n],n]//
>           Flatten//FullSimplify)
>
> Log[Gamma[n + 1]]*(n + 1)^2 - Log[Gamma[n + 2]]*(n + 1)^2 -
>   (1/36)*n*(n*(14*n + 57) + 69) + Derivative[1, 0][Zeta][-2,
>    n + 2] + Zeta/(4*Pi^2)
>
> Table[soln,{n,0,5}]//FullSimplify
>
> {0, -(35/9), -(239/18) + Log, -(61/2) + Log,
>   -(521/9) + 36*Log + 9*Log, -(880/9) + 36*Log +
>    9*Log + 25*Log}
>
>
> Bob Hanlon
>
>>
>> From: Jean Guillaume Pyraksos <wissme at hotmail.com>
To: mathgroup at smc.vnet.net
>> Date: 2005/11/30 Wed AM 05:40:43 EST
>> Subject: [mg62722]  Problem with RSolve
>>
>> I can't get this one solved, can you help ?
>>
>> RSolve[{c[n] == c[n - 1] + (n^2) Log[n], c == 0}, c[n], n]
>>
>> I am interested in the principal part of c[n], which should be 1/2 n^2
>> Log[n]^2 ?...
>>
>> Thanks, using Mathematica 4.1.0.0
>>
>>    JG
>>
>>
>

```

• Prev by Date: Re: Problem with RSolve
• Next by Date: Re: 3D Plot of frequency data
• Previous by thread: Re: Problem with RSolve
• Next by thread: Visualization site updates