Bill Allombert on Tue, 6 May 2003 13:25:13 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Rademacher formula for p(n) with PARI |
On Tue, May 06, 2003 at 07:08:48AM +0200, Damien Wyart wrote: > Hello, > > I am quite new to PARI (and this list) and plan to implement > Rademacher's formula for p(n) using PARI. As this is a classical result, > maybe some people here have already done this. Any hints or code > snippets would then be very welcome. PARI 2.2.5 development version include a function numbpart that implement Hardy-Ramanujan-Rademacher's formula. ? numbpart(17) %1 = 297 Here the comment which include a GP implementation: /* Original code contributed by: Ralf Stephan (ralf@ark.in-berlin.de). * * This program is basically the implementation of the script * * Psi(n, q) = local(a, b, c); a=sqrt(2/3)*Pi/q; b=n-1/24; c=sqrt(b); * (sqrt(q)/(2*sqrt(2)*b*Pi))*(a*cosh(a*c)-(sinh(a*c)/c)) * L(n, q) = if(q==1,1,sum(h=1,q-1,if(gcd(h,q)>1,0,cos((g(h,q)-2*h*n)*Pi/q)))) * g(h, q) = if(q<3,0,sum(k=1,q-1,k*(frac(h*k/q)-1/2))) * part(n) = round(sum(q=1,max(5,0.24*sqrt(n)+2),L(n,q)*Psi(n,q))) */ Cheers, Bill.